Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nhibernate + QueryOver: filter with Where ignoring sensitive

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>(); 
like image 256
LeftyX Avatar asked Mar 09 '11 10:03

LeftyX


1 Answers

In QueryOver you can use following:

Domain.User User = Session.QueryOver<Domain.User>()
       .WhereRestrictionOn(x=>x.Login).IsInsensitiveLike("username")
       .SingleOrDefault();
like image 98
Sly Avatar answered Sep 28 '22 06:09

Sly