The Model as below:
public class User
{
public int Id
public virtual ICollection<Tag> FollowingTags {get;set;}
}
public class Tag
{
public int Id
public virtual ICollection<User> Followers {get;set;}
public virtual ICollection<Post> Posts {get;set;}
}
public class Post {
public int Id
public virtual ICollection<Tag> Tags {get;set;}
}
That means there are two many-to-many from User to Post, perhaps it can be called a M:M:M relationship.
Now, if I want to find all posts with tags that followed by a certain User. I wonder what is the best practice with EF 4.1?
If use ADO.NET, I think joining two joint tables is effective way, but joint tables are hidden in EF, then how to do it ? I know some solutions, but the performance is not good, because the generated SQL not good enough. so I ask for a good query to get good performance.
Thank you!
1 Answer