I have a static function today that I pass a Property expression and I create a string from it:
public static string SomeFunction<TModel, TProperty>(TModel model, Expression<Func<TModel, TProperty>> expression){...}
I'd like to change it to process a list of expressions like this:
static string SomeFunctionForList<TModel, TProperty>(TModel model, List<Expression<Func<TModel, TProperty>>> expressions){...}
In the second case, I'd loop through the expressions and perform whatever logic I'm doing on them.
This is how I call the function now:
SomeFunction(this, m => m.nameOfProperty)
How would I specify a list of the expressions? I am trying this but it isn't working:
SomeFunctionForList(this,
new List<Expression<Func<TModel, TProperty>>> {
{ m => m.nameOfProperty1},
{ m => m.nameOfProperty2}
});
I'm getting a compiler error that TModel and TProperty cannot be found.
Aucun commentaire:
Enregistrer un commentaire