I have a situation in which two different modules of codes inserts and after some time deletes entity from UOW. So it creates unnecessery db operations.
I have a wrapper around the UOW and want to check whether I have entities in delete collection which are also in save collection (with isnew = true) and in such situation remove it from both collection.
Adding an entity for Deletion for it's IsNew = false, makes no sense.
So in this case the Delete routine should check in the InsertQueue of the UoW for matches.
If a match is found it should delete it from the queue, otherwise, do nothing.
I have an issue when entity is inserted via the entitycollection. In such case the unitOfWork.GetInsertQueue () doesn't return that entity as well as RemoveFromUoW doesn't handle that properly.
Should I also iterate through all collections to save and remove this object from such collection or there is some other way to achieve that ?
Before calling GetInsertQueue() you need to call ConstructSaveProcessQueues() Constructs the save process queues for insert and update actions. These queues are constructed from the entities added to this UoW for save either individually or in a collection