UOW ConcurrencyException

Posts   
 
    
Thorri
User
Posts: 13
Joined: 06-Jan-2009
# Posted on: 06-Jan-2009 17:31:28   

Hi. We are using UnitOfWork2 to save our object graph. But there is this ConcurrencyException (SD.LLBLGen.Pro.ORMSupportClasses.ORMConcurrencyException) that is thrown when we are trying do delete an object that does not exists, aka:Someone else have deleted this object (a classic Concurrency problem). This object graph of our contains several child entities that can sometimes by quite dynamic. Deleted at station X, and at same time deleted at station Y.

So is there any way for us to turn of this feature in UnitOfWork2 that throws an ConcurrencyException when 0 rows are updated ?

Best Regards Thorri

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 06-Jan-2009 21:36:19   

ORMConcurrencyException is only thrown on the delete of an entity if the entity has a delete restriction predicate specified as described here. Otherwise deletes should proceed without an error even if no record is deleted.

Is this the case in your code...?

If not, please could you post the code you are using to let us investigate further ?

Thanks

Matt

Thorri
User
Posts: 13
Joined: 06-Jan-2009
# Posted on: 07-Jan-2009 12:45:58   

No there is no delete restriction in our code, just a simple EntityCollection to delete

If we add a single entity to the list that does not exist in db a ORMConcurrencyException is thrown.

Here is the code we are using .

                
EntityCollection<CommonEntityBase> saveList = new EntityCollection<CommonEntityBase>();
saveList = AxxConverter.GetSaveList(a, saveList, Guid.Empty, "A");

EntityCollection<CommonEntityBase> deleteList = new EntityCollection<CommonEntityBase>();
deleteList = AxxConverter.GetDeleteList(a, deleteList, "A");

 using (DataAccessAdapter adapter = new DataAccessAdapter())
{
               UnitOfWork2 uow = new UnitOfWork2();
               uow.AddCollectionForSave(saveList);
               uow.AddCollectionForDelete(deleteList);
               int numberChanged = uow.Commit(adapter);
 } // using

br Thorri

Thorri
User
Posts: 13
Joined: 06-Jan-2009
# Posted on: 07-Jan-2009 12:55:42   

Here is the code for the save and delete converters list.


public static EntityCollection<CommonEntityBase> GetSaveList(Axx bo, EntityCollection<CommonEntityBase> saveList, System.Guid id, string scenario)
        {
            if (((bo.ObjectState == BaseObjectState.Changed) || (bo.ObjectState == BaseObjectState.New)))
            {
                AxxEntity entity = new eLSDal.EntityClasses.AxxEntity(bo.Id);
                entity.IsNew = (bo.ObjectState == BaseObjectState.New);

                //Do propertie mapping.
                saveList.Add(entity);
            }
            return saveList;
        }


        public static EntityCollection<CommonEntityBase> GetDeleteList(Axx bo, EntityCollection<CommonEntityBase> deleteList, string scenario)
        {
            if ((bo.ObjectState == BaseObjectState.Deleted))
            {
                AxxEntity entity = new eLSDal.EntityClasses.AxxEntity(bo.Id);
                entity.IsNew = false;
                deleteList.Add(entity);
            }
            return deleteList;
        }

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 08-Jan-2009 10:56:05   

What's the llblgen pro version you're using and the runtime library build nr? (See guidelines thread in this forum)

Frans Bouma | Lead developer LLBLGen Pro