部分类实体框架的属性已更改 [英] Partial class entity framework propertychanged
本文介绍了部分类实体框架的属性已更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在数据库优先的情况下,我有很多关系,并且将EF用作ORM& DAL:
With database first scenario, I have a many - many relation and use EF as ORM & DAL:
客户:ID,名称,地址||
产品:ID,名称||
CustomerProduct:CutomerID,ProductID
Customer: ID, Name, Address || Product: ID, Name || CustomerProduct: CutomerID, ProductID
我向Product实体类(称为Isincludedforcustomer)添加了一个自定义属性。
I add a custom property to the Product entity class , called Isincludedforcustomer.
public partial class Product: EntityObject
{
public bool isincludedforcustomer;
public bool Isincludedforcustomer
{
get { return isincludedforcustomer; }
set {isincludedforcustomer= value; }
}
当选择了一个顾客,我必须分配新的属性的方法。
When a Customer is selected, I have a method to assign the new property.
IsProductinclinframe(Displayedcustomerproducts, products);
我如何实现将属性更改为此属性?
How can i implement property changed to this property ?
推荐答案
我通常会在属性的设置器中调用PropertyChanged事件。
I generally put a call to the PropertyChanged event in the setter of the property.
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));
}
}
}
这篇关于部分类实体框架的属性已更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文