Hey guys,
We have an issue when we use Unit Of Work. Basically we group all the changes(inserts, updates, and deletes) in one unit of work. We are trying to delete two related records, for example like this:
Document entity, has fields:
Id int not null primary key,
Name string,
PrimaryShortCutID int nullable foreign key to ShortCut (ID)
ShortCut entity has fields:
Id int not null primary key,
Name string,
DocumentID int not null foreign key to Document (ID)
So lets assume we have one record for each entity which reference each other by both PrimaryShortCutID and DocumentID. We want to delete the record from Document entity.
In 3.1 we did this:
1. We set PrimaryShortCutID to null and add Document to UoW as AddForSave
2. We delete record from related ShortCut, by adding it to UoW as AddForDelete
3. We delete record from Document, by adding it to UoW as AddForDelete
In 4.1 you did the change in UnitOfWork2.cs in ConstructSaveProcessQueues method to skip saving of entities which are in _entitiesToDelete collection, and this causes a problem with step #1 i.e. PrimaryShortCutID is not set to null and thus the delete from ShortCut entity fail.
As for now, we did a temporary fix to use two UnitOfWork instances one for saving another for deletion. Is there any other way to fix it for us, or you will have to fix it on your end?
Currently we are using the latest version 5.1. Adapter template, SQL Server database, LlblGen Pro Framework.