Delete an entity in a collection

Posts   
 
    
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 07-Mar-2007 15:45:52   

Hi,

Why can I not create an entity instance, mark it for deletion, add it to a collection and call adapter.SaveEntityCollection and have it deleted whilst other entities in the collection are updated or inserted?

Cheers, Ian.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 07-Mar-2007 15:56:08   

You can do that. But we have created a special type of collection for this kind of scenario. We call it a Unit Of Work.

Please check the LLBLGen Pro manual: "Using the generated code -> SelfServicing/Adapter -> Unit of work and field data versioning"

jmeckley
User
Posts: 403
Joined: 05-Jul-2006
# Posted on: 07-Mar-2007 15:57:24   

add the entity to a UnitOfWork2 object instead of a collection.

UnitOfWork2 uow = new UnitOfWork2;
uow.AddEntityToDelete(myEntity);
uow.AddEntityCollectionToSave(myEntityCollection);
uow.Commit(adapter, true);
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 07-Mar-2007 18:22:52   

OK Thanks.