dynamic linq query
I have query to perform whe开发者_开发问答re the user will enter at runtime one of the columns to be included in the result set. And, I won't know until runtime how many columns he could choose from (he uploads a file that can contain a varying number of columns). I'd like to write the query where the index of the column is dynamic. What's the best way to do this kind of query?
Thanks.
You're looking for Dynamic LINQ.
Alternatively, you could generate expression trees from the column names and call ThenBy
in a loop.
精彩评论