Với đoạn mã sau, như thế nào EF/DbContext biết về sự thay đổi thực hiện cho các khách hàng đối tượng:Làm thế nào thay đổi theo dõi công trình trong Entity Framework
class Program
{
static void Main()
{
using(var shopContext = new ShopContext())
{
var customer = shopContext.Customers.Find(7);
customer.City = "Marion";
customer.State = "Indiana";
shopContext.SaveChanges();
}
}
}
public class ShopContext : DbContext
{
public DbSet<Customer> Customers { get; set; }
}
public class Customer
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string City { get; set; }
public string State { get; set; }
}
Cảm ơn bạn
Đối với những người mới tham gia, bài đăng trên blog này có thể hữu ích: http://blog.oneunicorn.com/2012/03/10/secrets-of-detectchanges-part-1-what-does-detectchanges-do/ – Karsten