NHibernate.Linq LIKE

前端 未结 4 1322
眼角桃花
眼角桃花 2021-02-12 10:02

How can I produce this query using NHibernate.Linq?

WHERE this_.Name LIKE @p0; @p0 = \'test\'  // Notice NO % wild card

Note, this is not Linq

4条回答
  •  借酒劲吻你
    2021-02-12 10:26

    I believe this is what you are looking for:

    var theaters = from theater in Session.Linq() 
                   where theater.Name.Contains("test") 
                   select theater;
    

    According to my tests it generates an SQL 'LIKE' statement: "... WHERE theater.Name LIKE %test%"

    which is exactly the output of the criteria snippet you have provided.

提交回复
热议问题