iQueryable and Expression Tree

c# expression-trees iqueryable lambda

Question

Can anybody explain me how to use (1) iQueryable (2) Expression Tree in C# by providing a very basic example? Both are not correlated, instead of making two separate questions, I wish to clear my doubt in a single question.

Advanced Thanks.

Popular Answer

Expression trees are very simple to make:

Expression<Func<int,int,int>> addExp = (a,b) => a + b;

or

var paramA = Expression.Parameter(typeof(int), "a");
var paramB = Expression.Parameter(typeof(int), "b");
Expression<Func<int,int,int>> addExp = Expression.Lambda<Func<int,int,int>>(
    Expression.Add(paramA, paramB),
    paramA,
    paramB);

Building an IQueryable provider is fairly difficult. However, Matt Warren has a very indepth series that walks you through creating an IQueryable provider.




Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why