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
|
We have implemented a base entity type that extends Mindscape.LightSpeed.Entity<TId>. We have overridden OnSaving() in order to be able to have a single point to update audit fields which we map to columns in tables in our database (CreatedBy, UpdatedBy). In the event the SaveChanges on a unit of work fails, the changes made during OnSaving() remain which in effect leaves the entity in an invalid state. Is there a way to somehow detect that a SaveChanges has failed, and thereby be given an opportunity to reset the state on the entity? |
|
|
You can't detect this from within OnSaving or any other entity event. I think the best you can do is to record in a UOW-level collection the changes you made to the audit fields. Then if SaveChanges throws an exception you can go through this collection rolling back those changes. |
|