How to do "... (a OR b) AND c ?

Posts   
 
    
seacat
User
Posts: 9
Joined: 26-Jan-2007
# Posted on: 11-Apr-2007 11:43:45   

Hi guys, I need get data accordingly this simple query:

select * from table where a = 1 and (b = 1 or b = null) and d =2

I use this code:


HelpPageCollection pages = new HelpPageCollection();
IPredicateExpression filter = new PredicateExpression();
filter.Add(PredicateFactory.CompareValue(HelpPageFieldIndex.PageNameSource,
                ComparisonOperator.Equal, pageName));       
filter.Add(PredicateFactory.CompareValue(HelpPageFieldIndex.PageDir,
ComparisonOperator.Equal, dirName)).AddWithOr(PredicateFactory.CompareNull(HelpPageFieldIndex.PageDir));


filter.AddWithAnd(PredicateFactory.CompareValue(HelpPageFieldIndex.SiteId,
                ComparisonOperator.Equal, siteId));
pages.GetMulti(filter);

But I have as result such query:

select * from table where a = 1 and b = 1 or (b = null and d =2)

Please, help me to construct the right code. Thanks!

Jessynoo avatar
Jessynoo
Support Team
Posts: 296
Joined: 19-Aug-2004
# Posted on: 11-Apr-2007 14:08:40   

Hi,

this is because (a or b) should be put in an inner predicate expression.

But have you tried using the operators overloads? That should make it easier than with the predicate factory, especially for nesting your expressions, since it does not need more than the appropriate parenthesis. Have a look in the manual.

Cheers

seacat
User
Posts: 9
Joined: 26-Jan-2007
# Posted on: 11-Apr-2007 15:27:43   

Jessynoo wrote:

Hi,

this is because (a or b) should be put in an inner predicate expression.

But have you tried using the operators overloads? That should make it easier than with the predicate factory, especially for nesting your expressions, since it does not need more than the appropriate parenthesis. Have a look in the manual.

Cheers

Can you give me a little sample? I have not found any topics as "operators overloads"...

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 11-Apr-2007 16:23:56   

Please refer to the LLBLgen Pro manual: "Using the generated code -> Adapter/SelfServicing -> Filtering and sorting -> Getting started with filtering"