有人可以帮我翻译这个查询到NHibernate Criteria吗?或者Criteria不适合这个吗?
查询:
SELECT b.*
FROM Bookmarks b
JOIN (SELECT tg.BookmarkId
FROM TagsBookmarks tg
JOIN Tags t ON t.id = tg.TagId
WHERE t.Title IN ('c#','tutorials')
GROUP BY tg.BookmarkId
HAVING COUNT(DISTINCT t.Title) = 2) x ON x.BookmarkId = b.Id
答案 0 :(得分:0)
Hibernate不允许from
子句中的子查询。您可以使用in
重写此内容:
SELECT b.*
FROM Bookmarks b
where b.id in (SELECT tg.BookmarkId
FROM TagsBookmarks tg JOIN
Tags t
ON t.id = tg.TagId
WHERE t.Title IN ('c#','tutorials')
GROUP BY tg.BookmarkId
HAVING COUNT(DISTINCT t.Title) = 2
)