Home > Net >  ExpressionVisitor analytic expression tree
ExpressionVisitor analytic expression tree

Time:09-26

Suppose there is such an expression tree
 Expression Expression1=c=& gt; (c.I d & gt; 5 & amp; & C.N ame. The Contains (" asdd ") | | (c.I d==1 | | c.I d==2). 


Now the expression c.I d & gt; 5, from ame. The Contains (" asdd ") this kind of has been parsed out do not have what problem

The key is how can the circle enclosed in parentheses "()" also parse out, otherwise such a condition, express not to come out of the original meaning

CodePudding user response:

Expression trees are not already structure to you?

For example:
Binary expression OrElse,
On the left: (c.I d & gt; 5 & amp; & C.N ame. The Contains (" asdd "))
On the right is: (c.I d==1 | | c.I d==2)

Can see the effect has been reflected in the expression in brackets,

CodePudding user response:

reference 1st floor github_36000833 response:
expression tree is not already give you the structure?

For example:
Binary expression OrElse,
On the left: (c.I d & gt; 5 & amp; & C.N ame. The Contains (" asdd "))
On the right is: (c.I d==1 | | c.I d==2)

Can see the effect has been reflected in the expression in brackets,


Yes, I can take to use ExpressionVisitor expression Member, BinaryExpression, Constant, Method of this a few parts, but how circular braces? Don't want to regular match up?

CodePudding user response:

reference 1st floor github_36000833 response:
expression tree is not already give you the structure?

For example:
Binary expression OrElse,
On the left: (c.I d & gt; 5 & amp; & C.N ame. The Contains (" asdd "))
On the right is: (c.I d==1 | | c.I d==2)

Can see the effect has been reflected in the expression in brackets,


My purpose is that translate incoming expression into Sql query conditions

CodePudding user response:

Logically, you already don't need the brackets,
Parentheses, has reaction to express tree.

CodePudding user response:

reference 4 floor github_36000833 response:
logically, you already don't need braces,
Parentheses, has reaction to express ,


Now I finished translating so Id & gt; 5 AND Name like '% asdd %' OR Id=1 OR Id=2

CodePudding user response:

If according to the meaning of the expression should be (Id & gt; Asdd % 5 AND Name like '%') OR (Id=1 OR Id=2) this way

CodePudding user response:

reference 1st floor github_36000833 response:
expression tree is not already give you the structure?

For example:
Binary expression OrElse,
On the left: (c.I d & gt; 5 & amp; & C.N ame. The Contains (" asdd "))
On the right is: (c.I d==1 | | c.I d==2)

Can see the effect has been reflected in the expression in brackets,


OrElse, binary expression - & gt; The corresponding SQL OR
On the left - & gt; Corresponding hypothesis L
On the right - & gt; Corresponding hypothesis R

SQL is not (L) OR (R)
The L and R extension, is not the result you want: ((Id & gt; 5) AND (Name like '% asdd %')) OR ((Id=1) OR (Id=2))

CodePudding user response:

refer to 7th floor github_36000833 response:
Quote: refer to 1st floor github_36000833 response:

Expression trees are not already structure to you?

For example:
Binary expression OrElse,
On the left: (c.I d & gt; 5 & amp; & C.N ame. The Contains (" asdd "))
On the right is: (c.I d==1 | | c.I d==2)

Can see the effect has been reflected in the expression in brackets,




OrElse, binary expression - & gt; The corresponding SQL OR
On the left - & gt; Corresponding hypothesis L
On the right - & gt; Corresponding hypothesis R

SQL is not (L) OR (R)
The L and R extension, is not the result you want: ((Id & gt; 5) AND (Name like '% asdd %')) OR ((Id=1) OR (Id=2))


I see what you mean, thank you! I began to want to have a deviation, I think can also like take rest of rewriting method can take to the brackets
  •  Tags:  
  • C#
  • Related