score:3

Accepted answer

just set the body to be the second parameter, p2. you already have the reference.

var p1 = expression.parameter(relationshipitems.elementtype, "i");
var p2 = expression.parameter(instanceentities.elementtype, "o");
var body = p2;
var lambda = expression.lambda(body, p1, p2);

score:0

if, for the sake of example, we assume p1 is an int and p2 is a string then this:

var p1=expression.parameter(typeof(int),"i");
var p2=expression.parameter(typeof(string),"o");

var lambda=expression.lambda(p2,p1,p2);
var function=lambda.compile() as func<int,string,string>;
var result=function(10,"hello");

will generate a function that returns "o". the lambda will return the value in the last expression in its body, which in the above example is just the parameter p2.


Related Query

More Query from same tag