Yeah, it was actually working. I'm being goofy, I added the wrong
restriction value in so I wasn't seeing the results I wanted.
Both of the examples I provided:
criteria.Add(!Expression.Eq("ChildFormID",1));
and
criteria.Add(Expression.Not(Expression.Eq("ChildFormID",1)));
Work just fine.
On Aug 25, 1:06 pm, John Davidson <[email protected]> wrote:
> Criteria.Add(Criterion.Restrictions.Not(Criterion.Restrictions.Eq(<PropertyName>,
> Value)))
>
> John Davidson
>
>
>
> On Wed, Aug 25, 2010 at 1:56 PM, MattO <[email protected]> wrote:
> > This one is throwing me for a bit of a loop and still don't know how
> > to write a "not equals" query.
>
> > In Hibernate for java there appears to be an Expression.ne (not
> > equals) that you can use. This doesn't exist in nHibernate 2.1.2.
>
> > So I tried this:
>
> > criteria.Add(!Expression.Eq("ChildFormID",1));
>
> > and also this:
>
> > criteria.Add(Expression.Not(Expression.Eq("ChildFormID",1)));
>
> > But neither of those have the desired effect of writing out my WHERE
> > SQL clause as follows:
>
> > WHERE ChildFormID <> 1
>
> > Instead what I get with the above two examples (but it is incorrect
> > for what I'm trying to accomplish) is
>
> > WHERE NOT (ChildFormID = 1)
>
> > So how do you do a "Not Equals" using Criterion API??
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "nhusers" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<nhusers%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nhusers?hl=en.- Hide quoted text -
>
> - Show quoted text -
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.