How do I perform a dynamic select in Linq?

Posted by Matt Mangold on Stack Overflow See other posts from Stack Overflow or by Matt Mangold
Published on 2010-05-19T19:21:25Z Indexed on 2010/05/19 19:30 UTC
Read the original article Hit count: 183

Filed under:
|
|

I am trying to figure out how to dynamically specify the properties for my select clause in a linq query.

Lets say I have a collection of employee objects. At run time, the end user will be specifying which properties they would like to see for those employees, so I need to be able to dynamically construct my Linq select clause.

I have used the dynamic Linq library, but I prefer not to use that, because it requires me to build a string to pass to the select method. I'd like to understand how to do this via Expressions.

© Stack Overflow or respective owner

Related posts about dynamic

Related posts about LINQ