Ok, I’m lost. Why is the 1st function WRONG (squiglies in the lambda expression), but the 2nd one is RIGHT (meaning it compiles)?
public static Expression<Func<IProduct, string, bool>> IsValidExpression(string val)
{
return (h => h.product_name == val);
}
public static Expression<Func<IProduct, bool>> IsValidExpression2()
{
return (m => m.product_name == "ACE");
}
Your first function is going to need two arguments.
Func<x,y,z>defines two parameters and the return value. Since you have both anIProductand astringas parameters, you’ll need two arguments in your lambda.Your second function is only
Func<x,y>, so that means that the function signature has but one parameter, and thus your lambda statement compiles.