NHibernate 3.0 search with substring

nhibernate

Solution

I checked the NHibernate source and the `ExpressionProcessor` for the `QueryOver` string like you posted above does not support `Contains`. The operations it supports are IsLike and IsIn. You could either use `IsLike` or if you are keen on Contains, use Linq. For example :

(from user in db.Users 
where names.Contains(user.Name)
  select user);

or

query.Where(person.Name.IsLike("%test%")) //In QueryOver

I am guessing that you got an "`Unrecognised method call`" exception.

Problem

I'm making a search with NHibernate 3.0 IQueryOver, where I have a keyword for a search. I need to search in a string to see if it is part of the string, ``` Query().Where(e => e.Name.Contains(keyword)).List(); ``` But this does not do the job as expected. How should such a search be performed?

Original source