使用NHibernate对串联全名进行模糊搜索

使用NHibernate对串联全名进行模糊搜索,第1张

使用NHibernate对串联全名进行模糊搜索

NHibernate无法将表达式转换为sql语句,因为它不知道如何处理c => c.FirstName +’‘+
c.LastName。解决方案可以将其重写为如下形式:

Session.CreateCriteria<Customer>()    .Add(Restrictions.Like(    Projections.SqlFunction("concat",      NHibernateUtil.String,      Projections.Property("FirstName"),      Projections.Constant(" "),      Projections.Property("LastName")),    "Bob Whiley",    MatchMode.Anywhere))


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5618356.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-15
下一篇2022-12-15

发表评论

登录后才能评论

评论列表(0条)

    保存