私はEvaluationRounds
が特定の学生と必要なアプリケーションを作成しています。関連するエンティティを複数のブランチおよび複数のレベルで読み込む
すべてはプロジェクトから始まります。プロジェクトには多くのグループがあります。グループには多くのメンバーがいますが、1人のメンバーも多くのグループに属しています。これは結合表によって行われますProjectGroupMembers
一方、プロジェクトは多くの評価ラウンドを持っています。
現在、私はこのLINQ文を持っている:
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を処分するために使用してステートメントを使用します。
EvaluationRoundProject
とその親類にEvaluationRounds
が搭載されていないという問題があります。これは私たちが得るものです:
'((System.Data.Entity.DynamicProxies.EvaluationRound_7400F2ED13550F1E92655A802808E4B94D454A30979C80D0EEED31D0CB7D7005)(新しいSystem.Collections.Generic.Mscorlib_CollectionDebugView(activeEvaluationrounds).Items [0]))EvaluationRoundProject' は投げました型 'System.ObjectDisposedException'
の例外は、私が試してみました:
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
とも
を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