UnitOfWork implementation

Posts   
 
    
tomahawk
User
Posts: 169
Joined: 02-Mar-2005
# Posted on: 06-Feb-2006 21:10:18   

Hi there,

I have a UnitOfWork object. When adding an entity for Delete, this works:

MyEntity e = new MyEntity();
e.PKey = "Blah";
e.IsNew = false;
uow.AddForDelete(e);

uow._entitiesForDelete.Count is now 1.

Then, I try to remove the entity for deletion.

MyEntity e = new MyEntity();
e.PKey = "Blah";
e.IsNew = false;
uow.RemoveFromUoW(e);

but uow._entitiesForDelete.Count is still 1.

I assumed the Equals implementation for the UnitOfWork collections is the same as EntityCollections? This works for an EntityCollection, should it work the same way with UoW?

jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 07-Feb-2006 03:35:35   

Off the cuff, without being in front of code, I think the UoW works with object references, so you would need to pass in the object reference you want to delete. I don't think a new object with the same key will suffice. But, that's off the cuff; I could be wrong.

Jeff...

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 07-Feb-2006 07:16:19   

RemoveFromUoW works with ObjectIds(GUID) not PKs So it depends on the specific instance you have passed earlier. The ObjectId is set whenever you instantiate a new object.