Here is my method that I use to get one entity in an ASP.NET Web API application.[EnableQuery]public virtual HttpResponseMessage GetById([FromODataUri]int id){    // get concrete entity from repository    var entity = repository.GetById(id);   // check entity    if (entity == null)    {        var message = string.Format(No {0} with ID = {1}, GenericTypeName, id);        return ErrorMsg(HttpStatusCode.NotFound, message);    }    // problem    return Request.CreateResponse(HttpStatusCode.OK, SingleResult.Create(repository.Table.Where(t => t.ID == id)));}I'm using SingleResult for OData request (because $expand for single entity does not work if I do not create SingleResult). But in this case I repeatedly do almost the same action repository.GetById(id); and repository.Table.Where(t => t.ID == id).How can I improve it? 
Method GetById and SingleResult
c#;asp.net mvc;asp.net web api
You can wrap the single entity into an IQueryable.  Something like this should work:SingleResult.Create(new[]{entity}.AsQueryable());You could write a helper function that uses this trick to convert from a single T to an IQueryable<T>.  There may even be a built-in way of doing this.