c# - Cannot convert expression type 'lambda expression' to return type 'System.Linq.Expressions.Expression<System.Func<IProduct,string,bool>>' -
ok, i'm lost. why 1st function wrong (squiglies in lambda expression), 2nd 1 right (meaning 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 going need 2 arguments. func<x,y,z>
defines 2 parameters , return value. since have both iproduct
, string
parameters, you'll need 2 arguments in lambda.
public static expression<func<iproduct, string, bool>> isvalidexpression(string val) { return ((h, i) => h.product_name == val); }
your second function func<x,y>
, means function signature has 1 parameter, , lambda statement compiles.
Comments
Post a Comment