PredicateExpression

Posts   
 
    
JimFoye avatar
JimFoye
User
Posts: 656
Joined: 22-Jun-2004
# Posted on: 07-Jan-2005 05:09:55   

Does AddWithAnd() do something different than Add()? Seems like I should have to choose between AddWithAnd an AddWithOr when adding after the initial IPredicate, but I just used Add() and the generated query did have AND (which is what I wanted in this case).

cmartinbot
User
Posts: 147
Joined: 08-Jan-2004
# Posted on: 07-Jan-2005 05:37:01   

I've often wondered that myself. But it seems that AddWithAnd is meant for adding another predicate expression on top of another predicate expression. An expression stuck_out_tongue_winking_eye is one or more predicates.

If you think about it a bit, that totally changes logic in most, if not all, cases.

I'm not saying that my psuedo-code is exact output but, using just Add() results in:

s!='sd' AND k='jj'

Now, using AddWithAnd() results in:

(s!='sd') AND (k='jj')

BUT, if you already have those predicates defined without an AddWithAnd(), using AddWithAnd() will result in:

(s!='sd' AND k='jj') AND (kk=76)

The last example is A LOT different than saying:

s!='sd' AND k='jj' AND kk=76

Basically, from what I understand, the AddWith*() methods are meant to seperate logical expressions. Somebody correct me if I'm off-base here. wink

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 07-Jan-2005 09:33:04   

Add defaults to AddWithAnd. This is done so you can easily add predicates in a loop without having to worry if it is the first in the predicate expression or not.

cmartinbot: heh no that's not it. simple_smile Each PredicateExpression is surrounded by brackets '()'. So if you add predicates (not predicateexpressions) to a predicate expression with addwithand you won't get brackets.

Frans Bouma | Lead developer LLBLGen Pro
JimFoye avatar
JimFoye
User
Posts: 656
Joined: 22-Jun-2004
# Posted on: 07-Jan-2005 22:13:06   

Add defaults to AddWithAnd. This is done so you can easily add predicates in a loop without having to worry if it is the first in the predicate expression or not.

Ok, so is there a time when I should explicitly use AddWithAnd()?

Also, will you be throwing a party when you reach your 5000th post? stuck_out_tongue_winking_eye

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 08-Jan-2005 12:31:02   

JimFoye wrote:

Add defaults to AddWithAnd. This is done so you can easily add predicates in a loop without having to worry if it is the first in the predicate expression or not.

Ok, so is there a time when I should explicitly use AddWithAnd()?

You could avoid that, but for code readability you could use that method of course simple_smile It's there for completeness simple_smile

Also, will you be throwing a party when you reach your 5000th post? stuck_out_tongue_winking_eye

Of course! free beer for everyone! simple_smile

Frans Bouma | Lead developer LLBLGen Pro