如何对“和”进行分组& “或”在使用 subsonic 2x 的单个查询语句中
我在将以下内容转换
SELECT * FROM foo f WHERE
(f.name = 'name' AND f.date = '1980/02/2001')
OR
(f.name = 'another name' AND f.date = '1990/02/2001')
为时
new Select().From(Foo.Schema.TableName)
.Where(Foo.Columns.Name).IsEqualTo('name')
.And(Foo.Columns.Date).IsEqualTo('1980/02/2001')
.Or(Foo.Columns.Name).IsEqualTo('another name')
.And(Foo.Columns.Date).IsEqualTo('1990/02/2001')
遇到一些麻烦,如您所见,我不知道可以隔离两组“AND”并将它们放入“OR”语句中的方法。
我非常感谢您在这方面的帮助。
I am having some trouble in converting the following
SELECT * FROM foo f WHERE
(f.name = 'name' AND f.date = '1980/02/2001')
OR
(f.name = 'another name' AND f.date = '1990/02/2001')
to
new Select().From(Foo.Schema.TableName)
.Where(Foo.Columns.Name).IsEqualTo('name')
.And(Foo.Columns.Date).IsEqualTo('1980/02/2001')
.Or(Foo.Columns.Name).IsEqualTo('another name')
.And(Foo.Columns.Date).IsEqualTo('1990/02/2001')
as you can see I am not aware of the method which can isolate two groups of "AND" and put each of them in an "OR" statement.
I would really appreciate your help in this context.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用 .AndExpression() 和 .CloseExpression() 将部件包装在 barckets 中,
请参阅:http://biasecurities.com/2008/07/complex-sql-conditional-statements-with-subsonic-2-1/ 示例
You need to wrap the parts in barckets using the .AndExpression() and .CloseExpression()
See: http://biasecurities.com/2008/07/complex-sql-conditional-statements-with-subsonic-2-1/ for examples