tags:

views:

53

answers:

1

I have an enumeration of type int in my entity, UserStatus.

I want to get all users where the UserStatus <> Cancelled.

So:

Session.CreateCriteria(typeof(User))
.Add(Expression.Eq("UserStatus", (int)UserStatus.Cancelled)
.UniqueResult<User>();

The above is fore equal, I need to get not equal.

+4  A: 

Use this:

Session.CreateCriteria(typeof(User))
.Add(Expression.Not(Expression.Eq("UserStatus", (int)UserStatus.Cancelled))
.UniqueResult<User>();
zoidbeck