开发者

With DevForce Ideablade, how do I determine if a related entity has been removed from an entity?

开发者 https://www.devze.com 2023-03-21 09:38 出处:网络
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:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号