Using LIKE with LINQ to NHibernate in C#

The equivalent to LIKE via the LINQ to NHibernate provider is Contains. An example of a LINQ to NHibernate that will return a result set matching a search like parameter is below.

IQueryable<Classname> linqLIKE =
        (from m in session.Query<Classname>()
         where m.Code.Contains("%dex%")
         orderby m.CreateDate
         select m);
IList<Classname> ListLIKE = linqLIKE.ToList();

The above searches the mapped table via the Classname class where Classname.Code is LIKE dex. The LINQ to NHibernate provider generates the below SQL query.

SELECT classname0_.ID as ID13_,
        classname0_.CODE as CODE13_,
        classname0_.CREATEDATE as LASTINDE3_13_ 
FROM ClassName searchinde0_
WHERE classname0_.CODE like ('%'+@p0+'%') 
order by classname0_.CREATEDATE asc;
@p0 = '%dex%' [Type: String (4000)]