搜索文本包含QueryOver [英] Search text contains with QueryOver

查看:138
本文介绍了搜索文本包含QueryOver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做到这一点:

  VAR列表= Session.QueryOver<人>()
。凡(X => x.LastName.Contains(SEARCHTEXT))
&的.List LT;人>();



但我得到这个错误:未确认的方法调用:System.String:布尔包含(系统.String)



你有一个想法



更新:

 公共类Person 
{
公共虚拟字符串名字{获得;组; }
公共虚拟字符串名字{获得;组; }
}


解决方案

NHibernate的不具有直接的因为这个链接提到的C#相当于 http://nhibernate.info/blog /2009/12/17/queryover-in-nh-3-0.html




其他限制



一些SQL运算符/函数没有在C#中直接等同。
(例如,在SQL其中name LIKE'%安娜%')。这些运营商在限制类QueryOver
重载,所以你可以写:



。凡(Restrictions.On(C => c.Name)。 IsLike(%安娜%))



此外,还有一个内联语法来避免该类型的资格:



.WhereRestrictionOn(C => c.Name).IsLike(%安娜%)



I'm trying to do this :

var list = Session.QueryOver<Person>()
    .Where(x => x.LastName.Contains(searchText))
    .List<Person>();

but I get this error : Unrecognised method call: System.String:Boolean Contains(System.String)

Do you have an idea ?

Update :

public class Person
{
    public virtual string FirstName { get; set; }
    public virtual string LastName { get; set; }
}

解决方案

NHibernate does not have direct C# equivalent as mentioned on this link http://nhibernate.info/blog/2009/12/17/queryover-in-nh-3-0.html

Additional Restrictions

Some SQL operators/functions do not have a direct equivalent in C#. (e.g., the SQL where name like '%anna%'). These operators have overloads for QueryOver in the Restrictions class, so you can write:

.Where(Restrictions.On(c => c.Name).IsLike("%anna%"))

There is also an inline syntax to avoid the qualification of the type:

.WhereRestrictionOn(c => c.Name).IsLike("%anna%")

这篇关于搜索文本包含QueryOver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆