How to make a dynamic selection in Linq?

advertisements

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.


This looks like something that fits more with your requirements of not using dynamic linq.