Print Page | Close Window

receive notification changes of properties and one- and many-end of navigation properties

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2042
Printed Date: 14-May-2025 at 11:59pm


Topic: receive notification changes of properties and one- and many-end of navigation properties
Posted By: leeatkinson
Subject: receive notification changes of properties and one- and many-end of navigation properties
Date Posted: 03-Aug-2010 at 6:33am
Hi

I have a couple of questions:

1) I want to be notified when the user changes the value of a scalar property. I have implemented a property interceptor for its set - but I wonder if this the best, or should I use OnPropertyChanged?

2) I also need to be notified when the user adds an entity to the many-end of a navigation property - e.g. when an order line is added to an order, the order is notified either if the user calls myOrder.Lines.Add(myOrderLine) or myOrderLine.Order = myOrder. What is the best solution for this?

Thanks

Lee



Replies:
Posted By: GregD
Date Posted: 05-Aug-2010 at 6:37pm
  1. You can simply subscribe to the PropertyChanged event of an entity to be notified when the value of one of its scalar properties is changed.

  2. You can subscribe to the PropertyChanged event on the collection property; e.g.,
          
aCustomer.Orders.PropertyChanged += new PropertyChangedEventHandler(Orders_PropertyChanged);

          It will report changes in the list's Count and Items[] properties when an item is added to the collection.




Print Page | Close Window