NHibernate.Linq LIKE

前端 未结 4 1383
眼角桃花
眼角桃花 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:16

    With NH 4 (and probably a bit earlier), a built-in Like string extension is available within NHibernate.Linq namespace: Like(this string matchExpression, string sqlLikePattern). (It is defined on NHibernate.Linq.SqlMethods extension class.)

    using NHibernate.Linq;
    ...
    session.Query()
        .Where(t => t.Name.Like("test"));
    

提交回复
热议问题