I have a data source to which I will not bind the X collection. X should contain a subset of certain properties of type Y (say, Y has the properties PropOne, PropTwo, PropThree) Of course, this can be done with an anonymous type:
void DoBind() { myGrid.DataSource = myCollectionOfYs.Select(y => new {y.PropOne, y.PropTwo}); }
How can I change this method so that its caller can specify which properties to use in projection in a safe way? That is, something like strings:
var expressions = new List<Expression<Func<Y, object>>>(); expressions.Add(y => y.PropOne); expressions.Add(y => y.PropTwo); DoBind(expressions);
source share