Reputation: 101
The new WCF Data Services toolkit allows you to obtain a parameter, which contains a property called FilterExpression of type System.Linq.Expressions.Expression. This property contains all the filters provided in the query-string parsed as an expression tree. This can be useful to improve performance by carrying out the filter server side.
However, you cannot just pass the filter expression to a where clause. Assuming the filter expression is an Expression type, is there an easy way to make use of it in a server side linq to sql query?
This doesn't work: var query.Where(filterexpression).ToList();
Upvotes: 0
Views: 203
Reputation: 36594
What you need is anything that can be Expression< Func<TEntityType, bool> >
for any Queryable of type IQueryab<TEntityType>
.
Upvotes: 1
Reputation: 78848
Actually, if query
is of type IQueryable<T>
, you can pass in an Expression
. If you're using Linq to SQL, you should have access to IQueryable<T>
objects.
Upvotes: 0