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