Is there anyway to do a join to a select statement using NHibernate (QueryOver if possible)?
Here is the SQL I'm hoping to generate
SELECT r.MaxReading, r.MeterId, m.PreviousHours
FROM
Meters m
LEFT JOIN
(SELECT Max(mr.ReadingHours) as MaxReading, mr.AssetMeterId
FROM MeterReadings mr
WHERE mr.MeterId IN(1,2)
GROUP BY mr.MeterId) r
ON m.Id=r.MeterId
I did find this post, but it looks like the answer was to build a different query. Which makes me think this may not be possible.
I already figured out how to build the subquery piece, so any answer can just use a simple query in it's place as an example. Thanks!
据我所知,不可能在NHibernate中联接子查询,因为所有联接都必须来自对象模型中的关系。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.