Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top