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. > > -- 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.
