[英]Is it possible use the like command in queryover nHibernate? How can I do this?
I want to search through parts of the record, not only in accurate records. 我想搜索部分记录,而不仅仅是准确的记录。 In this exemple I search for the accurate records:
在此示例中,我搜索准确的记录:
var v = NhSession.QueryOver<Dados.Models.PersonModel>()
.Where(w=>w.Name == "Mary"))
.List();
I can do this by queryover or only with criteria? 我可以通过queryover或仅使用条件来做到这一点?
The answer is in the: WhereRestrictionOn
. 答案在:
WhereRestrictionOn
。 It could look like this 它可能看起来像这样
var v = NhSession
.QueryOver<Dados.Models.PersonModel>()
//.Where(w => w.Name == "Mary"))
.WhereRestrictionOn(w => w.Name)
.IsLike("Mary", MatchMode.Start);
.List();
The MatchMode
enum will decide where to put the '%' generated SQL Statement MatchMode
枚举将决定将'%'生成的SQL语句放在何处
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.