0

对于数据库第一场景,我​​有很多关系并将 EF 用作 ORM 和 DAL:

客户:ID、姓名、地址 || 产品:ID、名称 || 客户产品:客户 ID、产品 ID

我向 Product 实体类添加了一个自定义属性,称为 Isincludedforcustomer。

  public partial class Product: EntityObject 
{
    public bool isincludedforcustomer;
    public bool Isincludedforcustomer
    {
        get { return isincludedforcustomer; }
        set {isincludedforcustomer= value; }
    }

选择客户后,我有一种分配新属性的方法。

 IsProductinclinframe(Displayedcustomerproducts, products);

我如何实现属性更改为此属性?

4

1 回答 1

2

我通常在属性的设置器中调用 PropertyChanged 事件。

public partial class Product: EntityObject, INotifyPropertyChanged 
{
    public bool isincludedforcustomer;
    public bool Isincludedforcustomer
    {
        get { return isincludedforcustomer; }
        set 
        {
            isincludedforcustomer= value; 
            RaisePropertyChanged("Isincludedforcustomer");
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;

    private void NotifyPropertyChanged(String info)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(info));
        }
    }
}
于 2012-06-29T14:43:35.983 回答