All Questions
Tagged with expression-trees linq-expressions
47 questions
2
votes
2
answers
87
views
Dynamically created event handler that writes ito a `ref` parameter
I want to subscribe to any event existing on a given object, where I don't know the type in advance. I'm generatig event handler at run-time using System.Linq.Expressions.Expression.
The code I have (...
0
votes
1
answer
406
views
Combine 'Contains' with 'ToLower' in dynamic expression
I'm building a generic search using expressions, searching in all string properties of the model. However I'm having problems implementing 'Contains' alongside 'ToLower'.
Type elementType = typeof(...
0
votes
1
answer
816
views
Build an expression tree that can handle any type/class with a "TryParse()" method
i have the following method that returns a "value parser" delegate according to the input type. it works fine but i'd like to get rid of the switch statements and type checks and be able to ...
0
votes
0
answers
20
views
How do I convert a Linq expression to a Func<> to use? [duplicate]
I have built an expression tree which seems to result in an expression of type Expression<Func<object, bool>> and a return type bool which I think is what I want. But when I try to compile ...
1
vote
0
answers
146
views
How to initialize rule expression class
I am working on rules engine using expressions... wanting to implement expressions for and/or for composite rules... using the following stackoverflow thread as a reference: How to implement a rule ...
3
votes
0
answers
1k
views
How to merge two Expression<Func<T, object>>
I have a class:
public class Person {
public virtual string Id { get; set; }
public virtual string Name { get; set; }
public virtual int Age { get; set; }
public ...
1
vote
1
answer
1k
views
LINQ Expression could not be translated (Deep Query in EF Core)
My Error Message is as follows:
The LINQ expression
DbSet<WorkItemEntity>
.Where(w => w.Company.Name.ToLower() != null && "com" != null &&
w....
0
votes
1
answer
50
views
Can't create a condition for null values in an array?
I am using linq expression trees to build a query.
My array:
string[] { null, null }
condition I want to implement:
x == null ? null : x.ToLower()
My linq expression looks like this:
{Param_0 =>...
2
votes
1
answer
532
views
How to create expression for ordering string by length
I am new to expression tree.
I need to order my collection base on string length and then string.
I dont want to repeat my code for every entity.
Any body know how to write it with expression tree?
...
3
votes
1
answer
2k
views
I can dynamically create an Expression<Func<T, bool>> predicate ,but how do i create Expression<Func<T1,T2,bool>>
from this link i can dynamically create an Expression < Func< T, bool>> predicate
this code can dynamically create s=>s.Id == 1
ParameterExpression argParam = Expression.Parameter(typeof(User)...
2
votes
1
answer
864
views
Text query parsing in Sprache
I'm trying to write some code to match strings based on a pattern:
pattern: "dog and (cat or goat)"
test string: "doggoat" result: true
test string: "dogfrog" result: false
I'm trying to write a ...
0
votes
2
answers
2k
views
DateTime lambda expressions
I was testing the implementation in the thread answer https://stackoverflow.com/a/7891426/1468492 but I get an error trying to parse an expression with a DateTime, for instance: t => t.Name == "...
1
vote
1
answer
680
views
Column Mapping Using Expressions and Dictionary
I'm having trouble coding an expression for IQueryable object. I can't figure out the right way to use the expression to map a string to object properties.
this is my query object and mapping ...
2
votes
1
answer
3k
views
Expression parameter is not defined
I am trying to perform a query against a list to give immediate results using an expression that is set elsewhere in the code, while a second thread goes off and uses it to get a full set of results ...
0
votes
1
answer
807
views
How do I create a lambda expression using return value from another lambda expression? [duplicate]
Neither the question nor the answer is the same as the question "Convert Linq expression “obj => obj.Prop” into “parent => parent.obj.Prop”". The only duplicate I've found on here lately is the ...