Is there a way to pass an order by clause to a DbSet class in EF?
I'm using C#
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)
What about using .OrderBy
directly on the Entity?
db.Employees.OrderBy(p => p.Id);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With