tags:

views:

34

answers:

1

I am using Expression.In() as a part of a criteria using NHibernate and for the life of me I can't find any way to make it ignore case. Does anyone know how this can be done or am I going to have to do this a different way?

Not that it probably matters much but here is a sample of how I am using the Expression.In()

ICriteria criteria = Session.CreateCriteria(typeof (Result))
    .Add(Expression.In("targetName", {'target1', 'target2'}));
+1  A: 

I think case handling differs for each db server. For example, by default mssql server is case-insensitive. So either check into that setting on your db or convert all strings to upper or lower before comparing.

.Add(Restrictions.In(
    Projections.SqlFunction("lower", NHibernateUtil.String, Projections.Property("targetName")), 
    new object[] {"target1", "target2"} ))
dotjoe
This worked great for sqlite and mysql, thanks a bunch.
mockedobject