Subsonic Complex SQL conditional statements - Condition1 And (( Condition2 And Condition3) OR (Condition4 And Condition5))

StackOverflow https://stackoverflow.com/questions/7715773

  •  08-02-2021
  •  | 
  •  

Domanda

How do I build a query in Subsonic that of this format:

Condition1 And (( Condition2 And Condition3) OR (Condition4 And Condition5))

The originial SQL Query is:

SELECT * FROM Events WHERE Deleted=false AND ((DateModified IS NOT NULL AND DateModified BETWEEN @date1 AND @date2) OR (DateModified IS NULL AND DateCreated BETWEEN @date1 AND @date2))

I've tried arious approaches, using AndExpreession(), OrExpression(), OpenExpression(), CloseExpression() but I cant seem to get the desired result.

Thanks in advance for your answer.

È stato utile?

Soluzione

For that particular query, why not get rid of all the parenthesis and simply let the operator precedence take over:

Condition1 And Condition2 And Condition3 OR Condition1 And Condition4 And Condition5

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top