本文介绍了NHibernate的+ QueryOver:与凡无视敏感的过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想建立NHibernate的与QueryOver一个简单的查询,但我想这一切小写转换或忽略大小写的:
Domain.User用户= Session.QueryOver< Domain.User>()
。凡(X => x.Login ==用户名)
.SingleOrDefault();
我怎样才能做到这一点?
更新
有人建议,这个问题可能是与DB的总汇,但我从来没有过什么样的问题与和这个脚本工作:
Domain.User用户=会话
.CreateCriteria< Domain.User>()
。新增(Expression.Eq(登录,用户名))
.UniqueResult< Domain.User>();
解决方案
在QueryOver你可以使用下列内容:
Domain.User用户= Session.QueryOver< Domain.User>()
.WhereRestrictionOn(X => x.Login) .IsInsensitiveLike(用户名)
.SingleOrDefault();
I am trying to build a simple query in nHibernate with QueryOver but I want it to convert everything lower-case or ignore sensitive:
Domain.User User = Session.QueryOver<Domain.User>()
.Where(x=>x.Login=="username")
.SingleOrDefault();
How can I achieve this?
UPDATE:
Someone suggested that the problem could be with the colletion of the DB but I've never had any kind of problem with that and this script works:
Domain.User User = Session
.CreateCriteria<Domain.User>()
.Add(Expression.Eq("Login", "username"))
.UniqueResult<Domain.User>();
解决方案
In QueryOver you can use following:
Domain.User User = Session.QueryOver<Domain.User>()
.WhereRestrictionOn(x=>x.Login).IsInsensitiveLike("username")
.SingleOrDefault();
这篇关于NHibernate的+ QueryOver:与凡无视敏感的过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!