0

Suppose that we have two entities, Posts and Comments. Posts has a navigation property to Comments and vice versa:

public virtual ICollection<Comment> Comments { get; set; }

And also Comments has a navigation property to User:

public virtual User User { get; set; }

Now, how to query all Posts including only the last comment (by comment creation date) and the user who created it?

2
  • 3
    show the code you have tried Commented Jun 24, 2014 at 7:07
  • @Mak to load all posts with all comments including user simply we do: _db.Posts.Include(p => p.Comments.Select(p => p.User)).ToList(); but because of performance issues I want only the last comment with user who creates that. Commented Jun 24, 2014 at 7:22

1 Answer 1

4

Not possible with the current version of EF but you can vote for it here https://entityframework.codeplex.com/workitem/47

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.