我有一个实体框架查询,带来所有帖子和评论。 我试图将EF代码转换为T-SQL存储过程。这是EF代码,
(from post in context.Post
orderby post.Id descending
select new Post
{
Id = post.Id,
PostText = post.PostText,
Comments = (from c in context.Comment
where c.PostId == post.Id
orderby c.Id descending
select new CommentDto
{
Id = c.Id,
CommentText = c.CommentText
}
)
}).AsNoTracking();
如何将上述代码转换为T-SQL? 我是否需要使用帖子和评论表进行LEFT OUTER JOIN,然后在客户端进行过滤?