Cascading delete or update in LLBLGenPro

Posts   
 
    
DrDelete
User
Posts: 39
Joined: 23-Apr-2009
# Posted on: 04-Jun-2009 15:47:28   

Is cascading delete or update supported in LLBLGenPro 2.6 ?

rdhatch
User
Posts: 198
Joined: 03-Nov-2007
# Posted on: 04-Jun-2009 20:48:02   

Cascade Updates are supported.

myEntity.Save(True) <- True Flag is for Recursive Save.

I have Cascade Delete working. Supports both In-Memory & Database Deletes. Supports both Transaction & Unit Of Work. Determines proper delete commit order automatically.

Ryan

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 04-Jun-2009 22:42:28   

When you say CascaseUpdate and Delete are you refering to the DB server performing the Update/Delete for you based on the PK/FK relationships between the tables? or, as Ryan indicated in his message, do you mean that LLBLGen generates the updates/deletes for you on the client side ?

Matt

DrDelete
User
Posts: 39
Joined: 23-Apr-2009
# Posted on: 08-Jun-2009 08:43:17   

MTrinder wrote:

When you say CascaseUpdate and Delete are you refering to the DB server performing the Update/Delete for you based on the PK/FK relationships between the tables? or, as Ryan indicated in his message, do you mean that LLBLGen generates the updates/deletes for you on the client side ?

Matt

If I read a collection of orders and delete one of them and save the list, I expect that the orderlines are deleted also.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 08-Jun-2009 09:16:37   

Please read this: Tracking entity remove actions

DrDelete
User
Posts: 39
Joined: 23-Apr-2009
# Posted on: 08-Jun-2009 11:49:56   

Walaa wrote:

Please read this: Tracking entity remove actions

When reading this, my "scenario" can not be easly executed....

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 08-Jun-2009 15:01:41   

I see, I didn't underrstand your question well.

If I read a collection of orders and delete one of them and save the list, I expect that the orderlines are deleted also.

Why don't you define the cascade delete at the database level?

DrDelete
User
Posts: 39
Joined: 23-Apr-2009
# Posted on: 08-Jun-2009 15:07:07   

Walaa wrote:

I see, I didn't underrstand your question well.

If I read a collection of orders and delete one of them and save the list, I expect that the orderlines are deleted also.

Why don't you define the cascade delete at the database level?

Well.. in fact that is defined at database level already wink . I want to make sure that LLBLGenPro can handle this kind of DB-handling.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 08-Jun-2009 15:11:34   

If you have a graph in memory and you deleted an order and the database deleted the related orderlines, then you should refetch the graph again. (Refresh the graph in memory).

Oherwise database cascades should have nothing to do with LLBLGen Pro.

DrDelete
User
Posts: 39
Joined: 23-Apr-2009
# Posted on: 08-Jun-2009 15:15:56   

Walaa wrote:

If you have a graph in memory and you deleted an order and the database deleted the related orderlines, then you should refetch the graph again. (Refresh the graph in memory).

Oherwise database cascades should have nothing to do with LLBLGen Pro.

So LLBLGenPro has no mechanism in its own runtime code that can handle this... that is strange. Let say that a DBA adds a cascading rule to the database, then the code has to be rebuilt to get it work in client code.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 08-Jun-2009 15:21:59   

So LLBLGenPro has no mechanism in its own runtime code that can handle this

What exactly that you want LLBLgen to handle?

DrDelete
User
Posts: 39
Joined: 23-Apr-2009
# Posted on: 08-Jun-2009 15:35:31   

Walaa wrote:

So LLBLGenPro has no mechanism in its own runtime code that can handle this

What exactly that you want LLBLgen to handle?

Well... after some thinking about the best way is that the database handles the cascading delete, and in the code you already have no related entities in hand because the parent entity is already deleted from the list flushed

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 08-Jun-2009 15:40:53   

Exactly.