Search code examples
c#entity-framework-4.1code-first

Sorting data using EF DbSet


Is there a way to pass an order by clause to a DbSet class in EF?

I'm using C#


Solution

  • I am not sure how to do that from DbSet, but you can do this from DBContext by getting access to the IQueryable

    private readonly DbContext context;
    ...
    context.Set<T>().OrderBy(item => item.Property)