Checking referential integrity with the adapter approach

Posts   
 
    
mario.muja avatar
mario.muja
User
Posts: 37
Joined: 03-May-2005
# Posted on: 02-Jun-2005 09:18:10   

Hi, let's assume two entities: customers, orders - linked 1:n

With the adapter approach, I can use the entity objects customerEntity and orderEntity and the corresponding collections independently of the adapter.

When I add a new orderEntity to the corresponding ordersCollection, will it then be checked whether the corresponding customer exists in the customerCollection, even without using the adapter?

I ask this, because we plan to transport entity objects to a client PC. We want to provide support for the client to work offline. We plan to save serialized entity collections in an isolated storage, when the client is offline. We plan to allow the client to change the data in the isolated storage and later synchronize with the server database.

There is no database on the client. There is therefore no adapter. Only the independent entity objects/collections, which are changed by the user in offline mode.

Thanks a lot for your help.

Regards, Mario

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 02-Jun-2005 09:40:44   

mario.muja wrote:

Hi, let's assume two entities: customers, orders - linked 1:n

With the adapter approach, I can use the entity objects customerEntity and orderEntity and the corresponding collections independently of the adapter.

When I add a new orderEntity to the corresponding ordersCollection, will it then be checked whether the corresponding customer exists in the customerCollection, even without using the adapter?

I'm not sure what you want to achieve, but a Customer has an orders collection in your setup. This means that if you add an order entity to a customer's Orders collection: myCustomer.Orders.Add(myOrder), the linking is done for you. So if this is done on the client, and the client sents the customer back using remoting, the server will have myOrder still linked to myCustomer, so a recursive save will save customer, then order and sync PK-FK's.

I ask this, because we plan to transport entity objects to a client PC. We want to provide support for the client to work offline. We plan to save serialized entity collections in an isolated storage, when the client is offline. We plan to allow the client to change the data in the isolated storage and later synchronize with the server database.

There is no database on the client. There is therefore no adapter. Only the independent entity objects/collections, which are changed by the user in offline mode.

Use binary/soap serialization to keep the tracking/syncing information.

Frans Bouma | Lead developer LLBLGen Pro
mario.muja avatar
mario.muja
User
Posts: 37
Joined: 03-May-2005
# Posted on: 02-Jun-2005 10:02:54   

Thanks. I was not aware of the fact, that an added order is always related to an existing customer when it is added to the orders property of a customer object.

Regards, Mario

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 02-Jun-2005 10:29:36   

mario.muja wrote:

Thanks. I was not aware of the fact, that an added order is always related to an existing customer when it is added to the orders property of a customer object. Regards, Mario

That's the power of using an OO framework simple_smile You use objects and assign them to each other and build a graph from them. simple_smile

Frans Bouma | Lead developer LLBLGen Pro