views:

37

answers:

2

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.

+1  A: 

Check out Scott Gu's Blog.

It will explain exactly how to do it.

mcass20
Scott Guthrie explains how to use the Dynamic Linq Library; however, I don't to use that because it requires you to pass it strings. I am looking for a way to construct my queries that is Type Safe
Matt Mangold
A: 

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

Shane Fulmer