Hi,
I need to write with the NH criteria API, the equivalent of this SQL
query :
SELECT DISTINCT dbo.BuzzGallery.Name, AVG(dbo.BuzzUserArt.Rating) AS
EXPR1, dbo.BuzzGallery.Scrapped, dbo.BuzzGallery.DateCreated
FROM dbo.BuzzGallery INNER JOIN
dbo.BuzzGalleryArt ON
dbo.BuzzGallery.BuzzGalleryID = dbo.BuzzGalleryArt.BuzzGalleryID INNER
JOIN
dbo.BuzzUserArt ON
dbo.BuzzGalleryArt.BuzzUserArtID = dbo.BuzzUserArt.BuzzUserArtID
GROUP BY dbo.BuzzGallery.BuzzGalleryID, dbo.BuzzGallery.Name,
dbo.BuzzGallery.Scrapped, dbo.BuzzGallery.DateCreated
HAVING (dbo.BuzzGallery.Scrapped = 0)
ORDER BY EXPR1 DESC, dbo.BuzzGallery.DateCreated DESC
The diagram can be seen here: http://buzzmyart.s3.amazonaws.com/diag.jpg
So far, I've got the following. Note that I don't know how to
integrage the AVG part. Can someone help ?
ICriteria criteria = SessionManager.GetCurrentSession
().CreateCriteria(typeof(BuzzGallery));
criteria.SetResultTransformer(new
DistinctRootEntityResultTransformer());
criteria.AddOrder(Order.Desc("DateCreated"));
return criteria.SetCacheable(true).List<BuzzGallery>();
Thanks
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.