NHibernate.Linq像 [英] NHibernate.Linq LIKE
本文介绍了NHibernate.Linq像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用NHibernate.Linq生成此查询?
How can I produce this query using NHibernate.Linq?
WHERE this_.Name LIKE @p0; @p0 = 'test' // Notice NO % wild card
注意,这不是Linq To Sql或Entity Framework.这是NHibernate.
Note, this is not Linq To Sql or Entity Framework. This is NHibernate.
以下是使用ICriteria的所需查询:
Here is the desired query using ICriteria:
criteria.Add(Expression.Like("Name", "test"));
return criteria.List<Theater>();
推荐答案
对于NH 4(可能更早一点),内置的Like
字符串扩展名可在NHibernate.Linq
命名空间:Like(this string matchExpression, string sqlLikePattern)
中使用. (它在 NHibernate.Linq.SqlMethods
扩展类.
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<Theater>()
.Where(t => t.Name.Like("test"));
这篇关于NHibernate.Linq像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文