views:

449

answers:

1

I need to do a query which checks a column in a table of type integer. how can i use expression.sql(nHIbernate Criteria API) to get all the rows matches the given number. Thank you, Rey.

+1  A: 

Do you need to use Expression.Sql? Couldn't Expression.Eq work for you?

Reference Criteria Queries

Sample code:

IList cats = sess.CreateCriteria(typeof(Cat))
    .Add( Expression.Like("Name", "Fritz%") )
    .Add( Expression.Or(
        Expression.Eq( "Age", 0 ), //<---- here is the one you check for int equality
        Expression.IsNull("Age")
    ) )
    .List();
o.k.w