I would like to generate the following select statement dynamically using expression trees:
var v = from c in Countries
where c.City == \"London\"
You could use the IQueryable-Extensions here, which is an implemantation of the solution described by "Ethan J. Brown":
https://github.com/thiscode/DynamicSelectExtensions
The Extension builds dynamically an anonymous type.
Then you can do this:
var YourDynamicListOfFields = new List(
"field1",
"field2",
[...]
)
var query = query.SelectPartially(YourDynamicListOfFields);