Search text contains with QueryOver

I'm trying to do this :

var list = Session.QueryOver<Person>()
    .Where(x => x.LastName.Contains(searchText))

but I get this error : Unrecognised method call: System.String:Boolean Contains(System.String)

Do you have an idea ?

Update :

public class Person
    public virtual string FirstName { get; set; }
    public virtual string LastName { get; set; }


NHibernate does not have direct C# equivalent as mentioned on this link

Additional Restrictions

Some SQL operators/functions do not have a direct equivalent in C#. (e.g., the SQL where name like '%anna%'). These operators have overloads for QueryOver in the Restrictions class, so you can write:

.Where(Restrictions.On(c => c.Name).IsLike("%anna%"))

There is also an inline syntax to avoid the qualification of the type:

.WhereRestrictionOn(c => c.Name).IsLike("%anna%")

Looks like QueryOver doesn't support Contains method. You could try with IsLike restriction:

nhibernate queryover LIKE with expression trees NHibernate 3.0 search with substring queryover and (x like 'a' or y like 'a')

WhereRestrictionOn(x => x.FName).IsLike("a%") use like this

var data = session.QueryOver<tablename>()    
                  .JoinQueryOver<if another table present>(x => x.Empsals)    
                  .WhereRestrictionOn(x => x.FName).IsLike("a%")        

Need Your Help

Get list of local computer usernames in Windows

c# windows

How can I get a list of local computer usernames in windows using C#?

What does being schema-less mean for a NoSQL Database?

nosql schema

Schemaless is a term that is currently floating around in the NoSql world.