Linq Expression Tree

Linq Expression : Switching between data Structure and code
///////////////////////////////////////////// /// Linq Expression Tree for (x,y ) => x * y; /// Directly build the lambda expression /// /////////////////////////////////////////////
Expression lambdaExpression1 = (x, y) => x * y; Func lamba1Delegate = lambdaExpression1.Compile(); int resultLamda1 = lamba1Delegate(100, 100);
Console.WriteLine(resultLamda1.ToString());
/////////////////////////////////////////////
Or you can do the following
Expression Func int int int AddOperation = (x, y) => x + y; int result = AddOperation.Compile()(10, 10);
///////////////////////////////////////////// ///// Rebuilding and Executing Linq Expression //// Manually ///////////////////////////////////////////// ParameterExpression p1 = Expression.Parameter(ty…
///////////////////////////////////////////// /// Linq Expression Tree for (x,y ) => x * y; /// Directly build the lambda expression /// /////////////////////////////////////////////
Expression lambdaExpression1 = (x, y) => x * y; Func lamba1Delegate = lambdaExpression1.Compile(); int resultLamda1 = lamba1Delegate(100, 100);
Console.WriteLine(resultLamda1.ToString());
/////////////////////////////////////////////
Or you can do the following
Expression Func int int int AddOperation = (x, y) => x + y; int result = AddOperation.Compile()(10, 10);
///////////////////////////////////////////// ///// Rebuilding and Executing Linq Expression //// Manually ///////////////////////////////////////////// ParameterExpression p1 = Expression.Parameter(ty…