0
,所以我有一個實體和複雜類型之間的簡單關係PropertyChanged事件,我想通知實體時,複雜類型的變化,在此代碼如何提高對延遲加載特性
[Table("Bills")]
public class Bill : NotifyBase
{
//how to call SetWithNotif when this changes ?
public virtual Discount Discount { get; set; }
}
[ComplexType]
public class Discount : NotifyBase
{
//some props in here
}
public class NotifyBase : INotifyPropertyChanged,INotifyPropertyChanging
{
public void SetWithNotif<T>(T val,ref T field,[CallerMemberName] string prop = "")
{
if (!field.Equals(val))
{
PropertyChanging?.Invoke(this, new PropertyChangingEventArgs(prop));
field = val;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(prop));
}
}
[field: NotMapped]
public event PropertyChangedEventHandler PropertyChanged;
[field: NotMapped]
public event PropertyChangingEventHandler PropertyChanging;
}