鉴于以下代码,EF/DbContext如何了解对客户对象所做的更改:
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 { …Run Code Online (Sandbox Code Playgroud) 我有一个对象,其中包含其他对象,其中包含其他对象,包括列表等.此对象是数据绑定到表单,在不同的选项卡中向用户公开了许多字段.我还使用了master-child datagridviews.
任何想法如何检查此对象中是否有任何相对于早期时刻发生了变化?不(手动)添加已更改的变量,在所有(> 100)设置方法中设置为true.
我们只说我有:
public Boolean booleanValue;
public bool someMethod(string value)
{
// Do some work in here.
return booleanValue = true;
}
Run Code Online (Sandbox Code Playgroud)
如何创建一个在booleanValue发生更改时触发的事件处理程序?可能吗?
.net c# event-handling inotifypropertychanged microsoft-metro