Lets suppose that I have the following simple query
var q =
from p in products
orderby p.ProductName descending
select p;
What would be the simplest and most straightforward way to specify the sort field and direction at runtime?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
We’ve used the dynamic linq library before to do this. Here’s a link to Scott Guthrie’s blog where he describes it.
Basically you could alter the above query to look like this: