I'm writing a new application and I want to populate the database with legacy data using XML files. So, the steps are as follows: 1) extract data from existing system, 2) create XML files, 3) import data from XML files then populate the bo's and call the save methods (which in turn runs all of the data through the validations).
The question involves this concept: a Company can have many Products. The XML file contains a denormalized list of company / product names ... consider for a moment that the first company has ten products ... the first round of importing adds one new record to the company table and ten new records to the Product table. I then save using a transaction. If nothing fails validation, the bo's should be set to IsDirty = false and ready for the next set of Company/Product pairs to be imported ... round two ... the next company is added which has 15 products. I add a new record to the company bo and 15 new records to the product bo. The company bo now has two records, one is saved to the db the other is not. The product bo now has 25 records, ten which have been saved to the db ... 15 have not.
My question is this: When I call the boProduct.Save() method (automatically saving the parent, boCompany, as they are in a parent child relationship) ... both bo's ignore the information in the rows that have already been saved ... correct? I believe this to be the case but I want to make sure first.
My second question: Should I call an initialize method to clear out the current data table prior to cycling the next Company / Product set through the import process? Assuming there are thousands of companies and tens of thousands of products, it is possible the current data table could have tons of unneeded data in them at the end of the process if I don't.
Thanks everyone,
CT
Charles T. Blankenship
Senior Consultant
Novant Consulting, Inc.
704.975.7152
http://www.novantconsulting.com