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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.