I need help converting this SQL statement, into EF4:
Select Posts.PostID, Post, Comment
from Posts left join
Comments on posts.PostID = Comments.PostID
Where CommentID not in
(
Select PostID
from Votes
where VoteTypeID = 4 --4 = flagged comment type
)
In my database, the Votes table stores either the PostID of reported posts, or CommentID of reported comments in the column Votes.PostID
Thanks in advance!
Update:
Based on my understanding you want all the posts, but for each post, you want to filter its comments, if that’s the case, you could use
ToDictionary:Note: uncomment the
Includemethod if lazy-loading is disabled, and you explicitly want to eager-load the comments in this query.Update2: