0

Hello guys. Im having a problem with the IsNull and IsNotNull Restrictions. What happens is that im trying to filter some table entries, and i do that by verifying if a certain field is null or not. The funny thing is that when i use "IsNotNull", it works properly, but when i use "IsNull" it shows nothing. It's like some entries are neither Null nor NotNull

case ProcessType.Termination:
                  criteria = criteria.CreateCriteria("Termination", "Termination").Add(Expression.IsNotNull("Id"));
                  break;
case ProcessType.Onboarding:
            criteria = criteria.CreateCriteria("Termination", "Termination").Add(Expression.IsNull("Id"));
            break;

The first case finds all proper elements. The second case finds nothing! Even though they (the other type of element) exist

Thanks in advance

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by schaibaa
0

This is because by default NHibernate is doing an inner join - so when you think about it, if you're inner joining those rows wouldn't exist. CreateCriteria has an overload where you can specify the join type - choose LeftOuterJoin and your query should work.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.