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>();
精彩评论