私は、次のコードを持っている:私を驚かせたということである、なぜ最後の行は、私はちょうど前の行で行われた変更を無視して、DBから二度目の行をフェッチしていることは何ですかEFがデータベースからデータをロードしてローカル変更を無視するのはなぜですか?
var existingParticipant = Context.CaseParticipants.Where(p => p.CaseId == caseId);
foreach (var cp in existingParticipant)
{
var ncp = caseParticipantList.First(a => a.Id == cp.Id);
cp.IsIncompetent = ncp.IsIncompetent;
cp.IsLeave = ncp.IsLeave;
cp.SubstituteUserId = ncp.IsPresent ? null : ncp.SubstituteUserId;
}
var withSubs = existingParticipant.Where(c => c.SubstituteUserId != null).ToList();
、どのように私はそれを避けるのですか?