troubleshooting Question

Lambda Expression Tree development problem.

Avatar of Evan Cutler
Evan CutlerFlag for United States of America asked on
.NET ProgrammingC#Editors IDEs
8 Comments1 Solution455 ViewsLast Modified:
I have this code:
MethodCallExpression methodSort =
      Expression.Call (typeof (Queryable), order, exprArgTypes, myads.Expression, lambda);

This code gives me:
   .Select (p => p)
   .OrderBy (p => p.Date_entered)  

to which I have in a IQUERYABLE output:
IQueryable orderedQuery = myads.Provider.CreateQuery (methodSort);

my problem is I am now trying to add a "Where" Clause in:
string qtype = "Title";
string query = "Fourth";

MemberExpression container = Expression.PropertyOrField (source, qtype);
Expression rightside = Expression.Constant(query);
BinaryExpression fullquery = MemberExpression.Equal(container, rightside);
LambdaExpression wlambda = Expression.Lambda(fullquery, source);

Type[] wArgTypes = { myads.ElementType, wlambda.Body.Type };

MethodCallExpression methodsearch =
	Expression.Call (typeof (Queryable), "Where", wArgTypes, myads.Expression, wlambda);

Two things go wrong:
1. The MethodCallExpression errors out, saying "Where" is not a method of IQUERYABLE.
2. I don't know how to combind methodsort and methodsearch into the same query? (is it a step 1, then step 2 thing?)

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros