특정 학생과 EvaluationRounds
이 필요한 곳에 응용 프로그램을 작성하고 있습니다.관련 엔터티 여러 지점 및 여러 수준로드
모든 것이 프로젝트로 시작됩니다. 프로젝트에는 많은 그룹이 있습니다. 그룹에는 많은 구성원이 있지만, 한 구성원도 여러 그룹에 속할 수 있습니다. 이것은 연관 테이블 ProjectGroupMembers
에 의해 수행됩니다. 반면에 프로젝트에는 많은 평가 라운드가 있습니다.
from r in _context.EvaluationRounds.Include(e => e.EvaluationRoundProject.ProjectGroups.Select(pg => pg.Persons))
.Include(e => e.Evaluations)
join g in _context.ProjectGroups on r.ProjectId equals g.ProjectId
join m in _context.ProjectGroupMembers on g.ProjectGroupId equals m.GroupId
where m.PersonId == studentId && r.EvaluationRoundStartTime < DateTime.Now && r.EvaluationRoundEndTime > DateTime.Now
select r
우리는 즉시 우리가 목록을 가지고로 dbcontext 처분 using 문을 사용
현재 나는이 LINQ 문이있다.
EvaluationRoundProject
및 그 친척에는 EvaluationRounds
이로드되지 않는 것이 문제입니다.
'. ((System.Data.Entity.DynamicProxies.EvaluationRound_7400F2ED13550F1E92655A802808E4B94D454A30979C80D0EEED31D0CB7D7005가) (새 System.Collections.Generic.Mscorlib_CollectionDebugView은 (activeEvaluationrounds) .Items [0])) EvaluationRoundProject' 던진 : 이것은 우리가 무엇을 얻을 또한
from r in _context.EvaluationRounds.Include("EvaluationRoundProject").Include(e => e.EvaluationRoundProject.ProjectGroups.Select(pg => pg.Persons)).Include(e => e.Evaluations) join g in _context.ProjectGroups on r.ProjectId equals g.ProjectId join m in _context.ProjectGroupMembers on g.ProjectGroupId equals m.GroupId where m.PersonId == studentId && r.EvaluationRoundStartTime < DateTime.Now && r.EvaluationRoundEndTime > DateTime.Now select r
및
을 : 나는 시도
유형 'System.ObjectDisposedException'의 예외
from r in _context.EvaluationRounds.Include(a => a.EvaluationRoundProject).Include(e => e.EvaluationRoundProject.ProjectGroups.Select(pg => pg.Persons)).Include(e => e.Evaluations)
join g in _context.ProjectGroups on r.ProjectId equals g.ProjectId
join m in _context.ProjectGroupMembers on g.ProjectGroupId equals m.GroupId
where m.PersonId == studentId && r.EvaluationRoundStartTime < DateTime.Now && r.EvaluationRoundEndTime > DateTime.Now
select r
편집 :이 코드
using (_context = new PeerEvaluationContext())
{
var activeEvaluationrounds = from r in _context.EvaluationRounds.Include(e => e.EvaluationRoundProject.ProjectGroups.Select(pg => pg.Persons)).Include(e => e.Evaluations)
join g in _context.ProjectGroups on r.ProjectId equals g.ProjectId
join m in _context.ProjectGroupMembers on g.ProjectGroupId equals m.GroupId
where m.PersonId == studentId && r.EvaluationRoundStartTime < DateTime.Now && r.EvaluationRoundEndTime > DateTime.Now
select r;
return activeEvaluationrounds.ToList();
}
편집 3를 사용하여 전체입니다 : :이 평가는 또한 evaluationround
Edit2가에로드되지 않습니다이 문제는 게으른 때문에 발생 적재가 사용됩니다. 그러나 나는 인터넷을 보러 갔다. 그리고 그들은 그들이 include
일부가 이것을 처리 할 것이다라고 말했다.
.ToList()? –
이미 그 질문에 대답을 추가 정보를 – freshrebel