Unit Of Work/remoting/new entities

Posts   
 
    
simmotech
User
Posts: 1024
Joined: 01-Feb-2006
# Posted on: 09-Apr-2008 11:58:55   

Our existing (non-LLBLGEN) server-side service typically has 'Save' and a 'Fetch' for each action it needs to perform.

The 'Fetch' method usually brings back child data along with the main item.

As part of the Save method and within the same transaction, we normally call the Fetch method to get back a new complete set of data and the client rebinds to it.

We are moving over to LLCoolJ for this app and made the Save method accept a UnitOfWork2 parameter (to allow easy bundling of delete entities within the graph).

For a new root entity, the Commit method ensures that the primary key (identity column) is updated with the value from the new row but what is the best way to find it again within the UnitOfWork2? We could: 1) Look in the UnitOfWork queues for an entity of the expected root type. 2) Add an additional parameter to the Save method which has the ObjectID of the root entity (which would be known on the client side)

3) Not use a UnitOfWork2 but pass in the root entity itself plus a collection of deleted entities. We could then create a UnitOfWork2 on the server side (or maybe just Save the entity recursively) 4) Create a new class solely for passing data to and from the server

Ideally we want a reasonable generic way of doing this (not .NET generics, necessarily) but a consistent way of passing parameters etc.

Any suggestions for the best way?

Cheers Simon

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 09-Apr-2008 12:27:52   

1) Look in the UnitOfWork queues for an entity of the expected root type. 2) Add an additional parameter to the Save method which has the ObjectID of the root entity (which would be known on the client side)

3) Not use a UnitOfWork2 but pass in the root entity itself plus a collection of deleted entities. We could then create a UnitOfWork2 on the server side (or maybe just Save the entity recursively) 4) Create a new class solely for passing data to and from the server

I've been using the first option.

Also the third one is a very good candidate.

You can combine both: 1- Pass the root entity with its related graph as a parameter 2- pass everything else in a UoW. 2- At Server Side add the root entity to the UoW.