nHibernate Criteria ---- Use of Expression.sql
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.
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();
精彩评论