Created
January 22, 2016 09:25
-
-
Save Fosna/c239f71f1a11bebbca1e to your computer and use it in GitHub Desktop.
It's suggested to use LINQPad 5 (download link: http://www.linqpad.net/download.aspx). How to build expression tree without lambda function. Use dynamic LINQ.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Expression<Func<int, int, int>> addExp = (a, b) => a + b; | |
Console.WriteLine(addExp); | |
var aArg = Expression.Parameter(typeof(int), "a"); | |
var bArg = Expression.Parameter(typeof(int), "b"); | |
var addBody = Expression.Add(aArg, bArg); | |
var buildAddExp = (Expression<Func<int, int, int>>)Expression.Lambda(addBody, aArg, bArg); | |
Console.WriteLine(buildAddExp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment