Subsonic 复杂 SQL 条件语句 - Condition1 And (( Condition2 And Condition3) OR (Condition4 And Condition5))
如何在 Subsonic 中构建以下格式的查询:
Condition1 And (( Condition2 And Condition3) OR (Condition4 And Condition5))
原始 SQL 查询是:
SELECT * 来自活动 在哪里删除= false AND ((DateModified IS NOT NULL AND DateModified BETWEEN @date1 AND @date2) OR (DateModified IS NULL AND DateCreated BETWEEN @date1 AND @date2))
我尝试了多种方法,使用 AndExpreession()、OrExpression() 、 OpenExpression()、CloseExpression() 但我似乎无法获得所需的结果。
预先感谢您的答复。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于该特定查询,为什么不去掉所有括号并简单地让运算符优先级接管:
Condition1 And Condition2 And Condition3 OR Condition1 And Condition4 And Condition5
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