Nhibernate Linq, Oracle and comparing to an empty string

 When you write an NHibernate Linq query you may want to include a predicate to check that a property/field has a value, which might look like this:

person.Email != ""

NHibernate will convert this to a sql expression

Email <> ''

Because oracle evaluates empty strings as null this does not work. The query will never return any rows. The best solution I could find was to use the string length

person.Email.Length > 0


Comments are closed