0
j'ai donc une relation simple entre une entité et un type complexe, et je veux en informer l'entité lorsque les changements de type complexe, comme dans ce codeComment élever événement PropertyChanged sur les propriétés chargées paresseux
[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;
}