对于数据库第一种情况,我有很多关系并使用EF作为ORM& DAL:
客户:ID,名称,地址|| 产品:ID,名称|| CustomerProduct:CutomerID,ProductID
我将自定义属性添加到Product实体类,名为Isincludedforcustomer。
public partial class Product: EntityObject
{
public bool isincludedforcustomer;
public bool Isincludedforcustomer
{
get { return isincludedforcustomer; }
set {isincludedforcustomer= value; }
}
选择客户后,我有一个方法来分配新属性。
IsProductinclinframe(Displayedcustomerproducts, products);
如何实现更改为此属性的属性?
答案 0 :(得分:2)
我通常会在属性的setter中调用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));
}
}
}