简体   繁体   中英

Dynamic ordering in Entity Framework

I've got to implement dynamic sorting in Entity Framework. I've found a piece of code that almost allows me to do this, but it doesn't work on navigation properties.

This works:

students.OrderBy("StudentName");

This does not:

students.OrderBy("Department.Ordinal");

This is the piece of code:

http://philsversion.com/2012/02/21/orderby-a-string-in-entity-framework/

How would I be able to change this to allow for the behavior I require?

Check System.Dynamic.Linq . I'm using it and it handles more complex queries also with parameters.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM