This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, I have a table with a one-many relationship with itself: Item -> ParentItemId Item.Parent is the property. When I update a particular property on Item, I need to propogate that value up the tree. I have overriden Item.OnSaving in which I do something like: if (Parent != null) { Parent.Prop += this.Prop; } So, I query an Item and then set its property. I then call UOW.SaveChanges(). At this point OnSaving is fired for that item. However any changes I make to OTHER Entities after this point are not part of the same UOW? If however I propagate changes BEFORE calling UOW.SaveChanges() everything works fine. To prevent having to call PropagateChanges() every time an Item is saved, it'd be great if I could do it through the OnSaving override. How would you suggest I tackle this? Ta - Imtiaz |
|
|
Have a read through the following thread - http://www.mindscapehq.com/forums/thread/342487 - as we have added a new event in the 4.0 nightlies which allows you to make modifications which will be included as part of the same change set which the entity which is firing the event was enlisted into. You would not need to call .SaveChanges() as part of this event callback however, as long as the entities you are modifying are attached to the same UnitOfWork then they will be included in the originating SaveChanges() batch. I believe this should cover what you are looking to achieve.
|
|