3 Aug 18:25
How to persist an entity when its within a collection of another entity
From: Scott Millett <scott <at> elbandit.co.uk>
Subject: How to persist an entity when its within a collection of another entity
Newsgroups: gmane.comp.programming.domain-driven-design
Date: 2008-08-03 16:25:40 GMT
Subject: How to persist an entity when its within a collection of another entity
Newsgroups: gmane.comp.programming.domain-driven-design
Date: 2008-08-03 16:25:40 GMT
I have a Customer entity and a Customer has an address book which is a collection of address entities. When I save a customer I don't really want to be looping through each of his addresses and persisting it to my database. To save a customer I use this code:~
aCustomer = Model.CustomerService.getCustomer(CustomerID) Model.CustomerService.SaveCustomer(aCustomer)
Model.CustomerService.SaveCustomer(aCustomer)And have it persist any changes that have been made to the customers address book? And how would I be able to save any changes without having to loop through the entire collection and saving each one individually. I am not using any O/R mapping tools.
Thanks for your help.
Scott
__._,_.___
__,_._,___
Dim
aCustomer As Model.CustomeraCustomer = Model.CustomerService.getCustomer(CustomerID) Model.CustomerService.SaveCustomer(aCustomer)
That all works fine and makes sense. Now if I wanted to Add, Edit or Remove a Customers Address I would use the code:
Dim aCustomer As Model.Customer
aCustomer = Model.CustomerService.getCustomer(CustomerID)
aCustomer.AddressBook(1).PostCode = "PO5 3ED"
Model.CustomerService.SaveCustomerAddress(aCustomer.AddressBook(1))
If this acceptable or should I be able to call simply
Model.CustomerService.SaveCustomer(aCustomer)And have it persist any changes that have been made to the customers address book? And how would I be able to save any changes without having to loop through the entire collection and saving each one individually. I am not using any O/R mapping tools.
Thanks for your help.
Scott
__._,_.___
Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe
__,_._,___
RSS Feed