score:1
Accepted answer
Use Expression.Call
var containsMethod = typeof(string).GetMethod(nameof(string.Contains), new[] {typeof(string)});
var predicate = Expression.Lambda<Func<Book, bool>>(
Expression.Call(
Expression.PropertyOrField(parameter, filterAfter)
, containsMethod
, new Expression[] { Expression.Constant(filterField) }
)
, parameter
);
Source: stackoverflow.com
Related Articles
- Convert expression tree from equal to contains
- Convert Contains To Expression Tree
- How to convert an expression tree to a partial SQL query?
- Opinions on Expression Tree Serialization Library from CodePlex?
- Translating expression tree from a type to another type with complex mappings
- Removing a single item from an enumerable source when the items are equal
- Combine property selector expression tree and value to create a predicate for EF filtering - create filter from lambda selector and value
- Create a Tree from a list of items, when each item contains a reference to its parent
- How to 'unquote' when creating Expression tree from lambda?
- creating Linq to sqlite dbml from DbLinq source code
- Selectively remove from where clause in LINQ expression tree
- Expression tree from IronPython
- Convert this Linq query from query syntax to lambda expression
- How to extract a where clause expression tree from IQueryable
- Code to apply expression tree directly to List
- variable is referenced from scope, but not defined LINQ expression tree
- Extracting the value from a Member Expression that contains a parameter
- Convert Lambda Expression into an Expression tree
- How to build a LINQ expression with Contains method from IEnumerable?
- How do I convert this LINQ query expression from C# to VB.NET?
- Convert this LINQ to dynamic Expression tree
- Convert expression tree types
- Convert this expression from Linq.IQueryable to Linq.ParalellQuery
- How to build expression tree from string values
- C# exclude duplicate code from two method returning expression
- How to select Item from an property list using Expression Tree in c#
- Cast function expression tree from object
- Custom expression for RavenDB where clause: field contains any item from provided array
- Convert linq expression from method syntax to query syntax
- Can't convert this linq to dynamic expression tree
- Looking to get information from two different tiers of nested lists
- Arrange List<> in ascending order
- Stock data carry over to next day in LINQ
- How to explicitly state the types when grouping in LINQ?
- LINQ Concat nested queries sorting
- Transform IEnumerable to DataTable to its primitive types
- Convert Nested For Loops into a LINQ Expression
- Alternative to .Contains in linQ and subqueries
- How to do a custom compare for every item in a intersect of two collections
- Filling a view model from entity data, getting convertion error
- Implementing Custom GroupBy function in VB.Net
- How to add multiple dynamic conditions or filters into LINQ query.?
- Need help in resolving error in predicates for And operator in LINQ
- How to filter out items that are in a list of a list?
- Instead of currency symbol I get a question mark into the Command Prompt
- Linq Query with SUM and ORDER BY
- Read text file word-by-word using LINQ
- How to filter data from datatable according to columns suffix
- Partial string matching in LINQ
- Take value from part of a LINQ query and add it to the result