开发者

NHibernate 3.1.0 : Select 1 subquery

How do I accomplish a s开发者_Go百科ubquery like "Select 1" in NHibernate 3.1.0?

In earlier versions, I know we used something like, .SetProjection(Projections.Constant("1")

In 3.1.0, .Select(1) is not possible, as Select(...) expects a Func<....> as a parameter.

Thanks.


there is an overload with Select(params IProjection projections) so you can write .Select(Projections.Constant("1"))


Here is the sample,

Session.QueryOver<Person>()
       .Where(p => P.Id == personId)
       .Select(Projections.Constant(1))
       .Take(1)
       .SingleOrDefault<int>();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜