Jim Menard <jim..o.com> wrote:
> I'd like to be able to build an expression that is a negation of
> another expression, but I can't figure out how to do so using Cayenne
> Expressions. In SQL, I want to do something like
>
> NOT (person.name LIKE '%Smith%' OR person.name LIKE '%Jones%')
>
> I know that I can write this as
>
> person.name NOT LIKE '%Smith%' AND person.name NOT LIKE '%Jones%'
>
> but can I build an expression the first way, with NOT?
>
> I can't simply rewrite the expressions using the latter example because
> I'm dynamically building an expression from smaller pieces.
Actually, you could using Boolean logic transformations, but it'd be a bit
more parsing work:
[If I remember correctly....]
NOT (A or B ...or C) = (Not A) and (Not B) ...and (Not C)
NOT (A and B ...and C) = (Not A) or (Not B) ...or (Not C)
I don't remember finding a unary NOT operator, but I didn't look that hard,
since, due to my pulldown-construction technique, it was enough that every
expression type I used also had a negated form.
I suspect there is one -- it's probably just not documented as well as the
rest, so you'll need to look through the expressions source code.
-Mike
This archive was generated by hypermail 2.0.0 : Mon Jan 19 2004 - 23:11:04 EST