I have a class:
public class User
{
public string Name { get; set; }
public int Age { get; set; }
}
Now I want to generate a list:
List<Expression<Func<User, object>>> selectorExpressions = /* ... */
That list is supposed to hold selector expressions for every property that match this example lambdas:
user => user.Name;
user => user.Age;
/* etc... */
What is the easiest way to achieve this?
EDIT: To clarify: I want to generate this list for every property in a class, e.g. something like this:
List<Expression<Func<User, object>>> selectorExpressions = Util.GetSelectorsForEveryProperty<User>();
I don't want to manually write lambdas for every property I need.
Aucun commentaire:
Enregistrer un commentaire