UnitOfWork.AddForDelete

Posts   
 
    
Chad2
User
Posts: 8
Joined: 19-Mar-2007
# Posted on: 22-Aug-2007 05:11:02   

Hi Guys,

I know from a previous thread that

AddForDelete only works on non-new entities. New entities are ignored by default. So you can't 'fix' a mistake in the UnitOfWork object handling using that method.

. Is there any way to get the UOW to delete those entities without having to burden the DB with a fetch of something that will be deleted anyhow?

unitOfWork2.AddForDelete(new SomethingXSomeotherthing(key,key));

In the system the UOW is manipulated at the client control layer(ui on top of that). When we save the entity both the UOW and entity is passed to the business layer via remoting. I really want to avoid having the CCL access the BML just to update the UOW. I can of course pass the list of entities to be deleted to the BML, fetch them and then add them to the UOW but it will become messy and defeat the nice clean save that will take an entity and UOW to update something.

Anything I've missed or will I just have to work around it?

Thanks.

Chad2
User
Posts: 8
Joined: 19-Mar-2007
# Posted on: 22-Aug-2007 05:31:22   

Guess I missed the simplest thing... Entity.IsNew is read/write. Since this will become part of the framework code I just have to ask if this flag will stay read/write in future?

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 22-Aug-2007 12:25:17   

Is there any way to get the UOW to delete those entities without having to burden the DB with a fetch of something that will be deleted anyhow?

You can delete entities directly using the UoW without fetching them, using UoW.AddDeleteEntitiesDirectlyCall() for Adapter & UoW.AddUpdateMultiCall() for SelfServicing.

Entity.IsNew is read/write. Since this will become part of the framework code I just have to ask if this flag will stay read/write in future?

Can't be 100% sure, but most probably it will, as it has always been. When we have major releases of LLBLGen Pro we list any changes that would break your code or logic.