With DevForce Ideablade, how do I determine if a related entity has been removed from an entity?
Let's say I 开发者_Go百科have a one-to-many relationship between Person and Pet entities (linked with a simple table with fields PersonID, PetID). If I do this:
aPerson.Pets.Remove(aPet);
bool result = aPerson.EntityAspect.HasChanges();
result is false after the call to HasChanges. How do I check if a related entity has been removed?
When you add/remove a Pet from a Person entity, the Person entity is not itself modified. That's why HasChanges is false.
Try the CollectionChanged event of the Pets navigation property instead:
aPerson.Pets.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Pets_CollectionChanged);
精彩评论