Transactions across two data sources

Posts   
 
    
Mali
User
Posts: 1
Joined: 24-Mar-2009
# Posted on: 01-Apr-2009 23:27:00   

I have an ASP page where I want to add/edit/delete and entity and its children all at once. Taking the example of an order and order-detail entities, I have two data grids and two detail views, bound to two llblgen data source objects.

Obviously one data source is bound to the order entities and a grid view and detail view is bound to it. The second grid view and detail view are nested inside the details view control. And show the order-details entity collection.

When I perform an add/edit operation on the order entity, I want to be able to add/update/delete order-details, and perform the save operation for all of them when I save the order entity.

As I have said I am using two llblgen data source controls for the parent and child. I was looking at a way to enable the transaction to work across both the data sources so that the entity and related children get saved on the PerformWork event.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 02-Apr-2009 05:24:25   

What I would do is, at the PerformWork event handler of the main data source control (Order), take the involved entityCollection of the detail data source, add it to the order entity to save/edit/delete, then save the whole graph.

The ASP.Net 2.0 DataBinding example at the LLBLGen Pro Examples section should give you an idea of this.

Another hint: you can pass a Transaction object to the unitOfWork.Commit method.

David Elizondo | LLBLGen Support Team