Did this improvement make it into ES2008? I'm still using an early release of ES2007 (upgrading take a bit of effort in my situation), and encountered the same problem.
I'm creating a search feature for my application that allows users to search the database using my custom UI. It isn't an open-ended UI: it just provides a series of inputs (title, version, created by, etc) and will build a dynamic query for all inputs the user selected, using either an and-based or or-based search. This works fine, and might generate a query like this:
Select * from users where firstname like '%da%' and lastname like '%k%' and createdbyuserid = 5 -- (could also be or's instead of ands)
The problem is that I'm now trying to combine searches, and running into issues with combined ands and ors. After combining multiple searches, I might get something like the following:
Code:
Select * from users
where
(firstname like '%da%' and lastname like '%k%' and createdbyuserid = 5)
or
(firstname like '%ai%' and lastname like '%k%')
or
(deletedon is not null or isactive = false)
So the and/ors are the same across one level ("and, and, or" for the individual searches, respectively, and "or" for the combined search), but any time I try to combine the esWhereItems from each item into one large query, everything either gets turned to ands or ors. I assume this is because the .And() and .Or() methods return List<esWhereItem>, which stores no information about whether they're and'd or or'd together. Obviously, this situation can't be solved by using an In term, as before.
Keep me posted (thanks).