Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I used to work with Entity Framework and made use of the Unit of Work pattern to store all changes during a request and commit them in a single transaction. Right now I am writing an Umbraco package which frequently uses the Umbraco code API to store or delete data from the database. For example the RelationService. Umbraco automatically saves changes when I call RelationService.Relate or RelationService.Delete.
I want to temporarily store these queries and execute them all in a single transaction when I want to commit my changes. Is this possible at all?
I see the RelationService internally uses Unit of Work and immediately commits changes. Can I somehow wrap another UoW around it and surpress commits made by the RelationService? How can I access the Unit of Work?
using (var uow = UowProvider.GetUnitOfWork())
var repository = RepositoryFactory.CreateRelationRepository(uow);
if (uow.Events.DispatchCancelable(SavingRelation, this, new SaveEventArgs<IRelation>(relation)))
uow.Events.Dispatch(SavedRelation, this, new SaveEventArgs<IRelation>(relation, false));
Unfortunately still didn't find a solution. It seems like the only way to solve this is by bypassing the Umbraco code API and firing custom SQL queries.
Umbraco has lots of events that fire on save, delete, etc. If you're surpressing the actual database saves in your own UoW, those events could be fired before it's actually persisted!
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted