Deleting Entities - Best Practice

Posts   
 
    
Kodiak
User
Posts: 92
Joined: 13-Apr-2009
# Posted on: 29-Dec-2009 11:57:10   

Hi,

I'm looking at what the best practice is for deleting an item from an entity collection (Eg. Order and Order Lines).

When an Order Line is removed/deleted by the user there is additional logic that must fire regarding additional fields etc that need to be modified on the main Order screen. The deletion of an order line may also lead to the automatic deletion of other order lines. All the deletion is to be performed in a Business Layer library.

What's everyone's thoughts?

Is the best way to tackle this to have the BL pass back some kind of collection of items to be removed, have the GUI process them in terms of UI adjustments and then tell the BL to actually delete them? This seems like a few extra steps. I'd prefer to have the BL actually delete the entities and pass back what entities were deleted but in LLBL it's impossible to access the properties of a deleted entity (due to the inbuilt exception). Sure - the objects been deleted from persistent storage but shouldn't you still be able to access it and see what was deleted or some IsDeleted property?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 30-Dec-2009 02:37:19   

Hi Kodiak,

I don't understand what is really the question/problem, and why you need to access the entity after deletion either. You can create a copy before delete it anyway.

And about the IsDelete field, please read this article first: http://weblogs.asp.net/fbouma/archive/2009/02/19/soft-deletes-are-bad-m-kay.aspx

David Elizondo | LLBLGen Support Team