Hi,
I have an entity Uitgave with a list of related entities of UitgaveTrede (pk UitgaveId). UitgaveTrede also has a unique constraint on two other fields (BovenTrede, ContractTypeId).
The Uitgave with UitgaveTredes are fetched in UitgaveEntity (with the related entities on navigator/relationship UitgaveTredes)
These are attched to a new DataScope
scope.Attach(uitgave);
The (list of) UitgaveTredes are now updated, items deleted, items added.
When calling CommitChangesAsync I get an exception
SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException: 'An exception was caught during the execution of an action query: Cannot insert duplicate key row in object 'dbo.UitgaveTrede' with unique index 'BovCon'. The duplicate key value is (2000,1).
This is because the work order is inserts and then deletes.
In a UnitOfWork I can change the order, but in a DataScope it is fixed and _uowWorkOrder is private
private List<UnitOfWorkBlockType> _uowWorkOrder;
And cannot be set.
Also, overriding protected virtual IUnitOfWorkCore BuildWorkForCommit() does not work because I cannot access _context:
protected virtual IUnitOfWorkCore BuildWorkForCommit()
{
return _context.CreateFilledUnitOfWork(this, _uowWorkOrder, _refetchStrategy);
}
Is there a work around by using the uow from BuildWorkForCommit()* directly and setting its CommitOrder (to set the deletes first and so on)? Are there any pitfalls by using this uow directly and/or do I have to do some extra work to make it work exactly as the CommitChangesAsync in the DataScope?
- I'm already using an inherited class of DataScope for some upfront checks and loggings where I also use this BuildWorkForCommit() upfront, so I already have access to the uow.
Thanks
Using 5.9 (5.9.3) RTM with adapter and Sql Server