开发者

nHibernate Criteria ---- Use of Expression.sql

开发者 https://www.devze.com 2022-12-15 05:45 出处:网络
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.

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();
0

精彩评论

暂无评论...
验证码 换一张
取 消