开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜