Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用DBContext和POCOs时如何连接导航属性更改_C#_.net_Entity Framework_Entity Framework 4.3 - Fatal编程技术网

C# 使用DBContext和POCOs时如何连接导航属性更改

C# 使用DBContext和POCOs时如何连接导航属性更改,c#,.net,entity-framework,entity-framework-4.3,C#,.net,Entity Framework,Entity Framework 4.3,我使用的是数据库优先编码策略,并由EF4.x DBContext Generator生成POCO和上下文 简而言之,当我使用ObjectContext时,为了触发通知,我扩展了如下实体: public partial class Customer { public Customer() { this.AddressReference.AssociationChanged += AddressReference_AssociationChanged;

我使用的是数据库优先编码策略,并由
EF4.x DBContext Generator
生成POCO和上下文

简而言之,当我使用ObjectContext时,为了触发通知,我扩展了如下实体:

public partial class Customer
{
    public Customer()
    {

        this.AddressReference.AssociationChanged += AddressReference_AssociationChanged;            
    }

    private void AddressReference_AssociationChanged(object sender, CollectionChangeEventArgs e)
    {
        OnPropertyChanged("Address");
    }

}
在使用DBContext和POCO时是否有类似的情况

编辑:


当Customer.Address=new Address时,我需要它作为变更通知。默认情况下,标量属性会引发更改通知,但导航属性不会。

可能与井重复,也可能。但具体地说,我完全知道EF动态代理在运行时扩展了基本POCO并实现了INotifyPropertyChanged,而且这些代理工作得不是很好。基本上这是另一个问题,但它有点相关,因为我在MVVM-WPF解决方案中实现了这一点。