I have method GetByID in my repository that return generic type:
public T GetById(object id)
{
return this.Entities.Find(id);
}
I'm going to use OData to filtering data, and for that (when I'm using $expand for single row) I need to something like:
SingleResult.Create(repository.GetByID(id));
But of course I got error, because for SingleResult needs type IQueryable<T>.
How can I implement it?
One bad solution is change my GetByID to:
public IQueryable<T> GetById(object id)
{
return this.Entities.FirstOrDefault(p => p.ID == (int)id);
}
But I prefer to use T GetById because in my opinion it is more correct.
What type should return GetByID? Could you please advise me what to do?