質問

実際にSaveChangesメソッドを適用する前に変更が検出されないのか理解できない。私はちょうど物事をテストするだけです。これがコード:

です
Lodging query = context.Lodgings.SingleOrDefault(d => d.LodgingName == "Hotel4");
context.Entry(query).Reference(l=>l.Destination).Load();

Console.WriteLine(query.Destination.DestinationName);
query.Destination.DestinationName = "Some Where Else";
Console.WriteLine(context.Entry(query).State);

Console.WriteLine(query.Destination.DestinationName);
context.ChangeTracker.DetectChanges();
Console.WriteLine(context.Entry(query).State);
Console.WriteLine(query.Destination.DestinationName);
.

出力は "変化しません"です。もちろん、変更を保存するとデータベースが更新されます。

役に立ちましたか?

解決

この説明は役に立つことができます: http://blog.oneunicorn.com/2012/03/10/secrets-of-detectchanges-part----does-detectchanges-do/

他のヒント

Your question doesnt explain about actual requirement.May be you will find the answer here.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top