开发者

NHibernate QueryOver with nested select in FROM

How would you write t开发者_JAVA技巧he following using QueryOver (or CriteriaAPI for that matter)?

select foo from (select 1 as foo) as bar


This is actually not totally obvious if you use the QueryOver interface - which is more complex and subtle than it first appears. Consider using NHibernate.Linq.LinqExtensionMethods.Query<T>:

session.Query<Person>().Select(p => p.Husband).Select(p => p.Name).ToList()

Will give you a List<string>, corresponding to the sql:

select h.name from (select husband as h from person) as h
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜