Вопрос

Я не понимаю, почему изменения не обнаружены, прежде чем я фактически применим метод 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-1-what-does-detectchanges-do/

Другие советы

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top