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;
}