프로젝트에 다음과 같은 시나리오가 있는데 몇 가지 질문이 있습니다. User
클래스에 공통적 인 일대 다 관계가있는 두 엔티티
Questions
및
QuestionFollows
쿼리보다
QuestionFollows
직접 (성능면에서) 더 좋을 것이다 쿼리?
또 다른 질문은 ... User
과 QuestionFollow
사이의 관계가 필요/환원제입니까? 당신이하고있는
도메인
public class User
{
public long UserID { get; set; }
public string Name { get; set; }
public virtual ICollection<Question> Questions { get; set; }
public virtual ICollection<QuestionFollow> QuestionFollows { get; set; }
}
public class Question
{
public long QuestionID { get; set; }
public long UserID { get; set; }
public string Description { get; set; }
public User User { get; set; }
public virtual ICollection<QuestionFollow> QuestionFollows { get; set; }
}
public class QuestionFollow
{
public long QuestionFollowID { get; set; }
public long QuestionID { get; set; }
public long UserID { get; set; }
public DateTime Date { get; set; }
public Question Question { get; set; }
public User User { get; set; }
}
사용자에 대한 질문 쿼리는 QuestionFollows를 쿼리하는 것과 동일한 행을 제공하지 않습니다. User에 대한 QuestionFollows는'User.Questions.SelectMany (x => x.QuestionFollows)'와 유사합니다. 이 경우 사용자가 직접 선택한 QuestionFollows는 select many 옵션보다 성능이 좋습니다. –