Removing from UnitOfWork

Posts   
 
    
Joerg
User
Posts: 5
Joined: 15-Jun-2005
# Posted on: 12-Jul-2005 17:34:59   

Hi, I am using the Adapter model, and I have added several entities to my UnitOfWork using the AddForDelete method. I would like to remove some of them, but it doesn't appear to be working.

Is it possible to call .RemoveFromUoW(MyEntity) ? This should remove the entity from the collection, but it appears to still be on there. I then attempted to loop through it manually using the GetEntityElementsToDelete method. I then want to get my entity from the Entity property on the UnitOfWorkElement object - however, it seems to be of type Entity instead of Entity2. Therefore, I cannot then remove the entity from the collection, as the RemoveFromUoW method requires an Entity2 entity, whilst the entity I get from the UnitOfWorkElement .Entity is not an Entity2 entity.

Does the RemoveFromUoW functionality really work for the Adapter model, or am I missing something in my implementation ...?

Joerg

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 12-Jul-2005 21:44:05   

RemoveFromUoW works on objectid's.

So you have to pass in the same instance with the same ObjectID otherwise it can't find it back.

It checks the individual added entities. If you added a collection for deletion, and the entity is in there, remove it from the collection instead, as that collection is evaluated when you call Commit().

Frans Bouma | Lead developer LLBLGen Pro