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
|
Hello, Consider a job that creates an arbitrary number of entities. When the entity is saved, some irrevocable action, such as sending an email, takes place. Due to the fact that I'm reusing my entities across projects, I'm coding against an instance of IUnitOfWork, thus I'm not overwriting its "SaveChanges" method. Under the current design of LightSpeed I can overwrite the OnSaving of the entity and perform that action (say sending an email). But now assume there are 20 entities to be saved, but for some reason, it fails at the 10th one. We have sent 9 messages while the actual entities were not saved. So when a user opens the message and clicks on a link to view the entity, the system reports a failure. From their perspective our system is unreliable. Unfortunately I don't see a way to work around the problem as-is. Is it possible to add a method, say OnSaved, to Entity which are called after the transaction used during the SaveChanges method is committed? I can overwrite this method in the respective entities and send the emails. This will prevent the problem where emails are sent for entities that were never committed due to a failure while saving the entities. Much appreciated. Werner |
|
|
Yes this is certainly possible! I will have a look at this soon and get back to you once we have something implemented and available to push out via a nightly.
|
|
|
Hi Jeremy, Just checking whether you had any chance to look into this. Werner |
|
|
Hi Werner, Its still in progress but thanks for the bump, Ill have another pass on this tonight for you.
|
|
|
Hi Werner, I have committed a change for this into tonights nightly build. There is now a Saved event which will be fired when SaveChanges completes the transaction around flushing the SQL statements to the database. As with before let me know if you have any feedback on this change.
|
|
|
Hi Jeremy, The change works great and addresses the issue perfectly. Thanks, Werner |
|