开发者

how to build Expression<Func<x,y>> with no input parameters?

开发者 https://www.devze.com 2023-03-01 13:49 出处:网络
I use Expression.Call to build MethodCallExpression dynamically.开发者_运维技巧 The call is for \"First\" method.

I use Expression.Call to build MethodCallExpression dynamically.开发者_运维技巧 The call is for "First" method. Then, I need to wrap it to Expression<Func<x,y>> (x and y are types, and it irrelevant to the question). I'm trying to do it with Expression.Lambda<Func<x,y>>, but get Incorrect number of parameters supplied for lambda declaration exception when passing

new ParameterExpression[]{} (i.e. empty array) in the ParameterExpression[] input parameter.

what should be provided to Expression.Lambda when the Lambda takes ZERO parameters?


Action is the delegate that corresponds to a void that accepts no parameters. Func<x, y> says that the method accepts an x and returns a y. All the Func delegates return values, and all the Action delegates are void.

0

精彩评论

暂无评论...
验证码 换一张
取 消