간단한 블로그 애플리케이션을 작성하여 MVC 및 nHibernate를 배우려고합니다.동일한 쿼리에서 Linq를 사용하여 Nhibernate에서 자식의 부모 및 개수를 선택하십시오.
게시물 테이블과 설명 테이블이 있습니다. 각 게시물은 여러 개의 댓글을 가질 수 있습니다. 이제 제 견해에서 나는 게시물의 세부 사항과 코멘트의 수를 표시해야합니다.
나는 아래의 코드 이것은 아래의 SQL을 반환(from post in DbContext.Posts
where post.ScheduledDate <= DateTime.Now && post.Approved == true
orderby post.ScheduledDate descending
select new { Post = post, CommentCount = post.Comments.Count() }).Take(10);
시도 :
SELECT top 10 count(comments1_.Id) as y0_
FROM Posts this_
left outer join Comments comments1_
on this_.Id=comments1_.PostId
WHERE (this_.ScheduledDate <= '2009-12-29' and this_.Approved = 1)
ORDER BY this_.ScheduledDate desc
을 분명히 group by
가 사용되지 않았다는 SQL 예외가 발생합니다.
어떤 버전의 NHibernate Linq 공급자를 사용하고 있습니까? 트렁크 나 NHContrib의 최신 버전은 DLL 하나를 분리합니까? –
기준 API를 사용하는 것을 사용하고 있습니다. NHContrib 하나 .. 트렁크에있는 것을 사용하는 것이 안전한가요? 초보자를위한 충분한 문서가있는 것처럼? – madaboutcode