Could you do a query with subqueries like this with nhibernate?
If you had a quer开发者_如何学Cy that looks like this, could it be converted into a nhibernate query?
SELECT ....
FROM
(
SELECT ...
FROM ...
GROUP BY...
ORDER BY ...
UNION
SELECT ..
FROM ...
)
AS ASDF
GROUP BY ...
ORDER BY ...
With hibernate you can do native SQL queries. You just need to create a named Sql query mapping, and map it to a class.
However, you will not get the benefit of writing to the named query. [Which is to be expected]
if by "nhibernate query" you mean to use any non-sql method to express an sql query, like using HQL
or the ICriteria
api, no you wouldn't be able to use the union
or to express a result set using select * FROM ( select ... ) as FOO
The named query that monksy refers to is writing an SQL-query that you bind to the mapping but you cannot manipulate that query in many ways
精彩评论