I am familiar with SubSonic 2.2 and am coming up to speed with 3.0 and am unsure of the best way to do something. I have a CSV file that I am parsing and then inserting the records into the database. I want to be able to process the batch of inserts all at once. IE I would like to parse through the records and add them to a List insertAll and if all records in the import pass validation I would like to Insert them all at once. Doing something like Repo.Insert(insertAll). What options do I have in SubSonic 3.0. Are Transactions my only way to go?
+1
A:
You can use the Add repository method to insert an IEnumerable list in a single transaction so you can do something like the following:
List<MyObject> = myObjects new List<MyObject>();
// Populate your MyObject List from your CSV file
SubSonicRepository<MyObject> repo = new SubSonicRepository<MyObject>(new MyDB());
repo.Add(myObjects);
Adam
2009-09-25 16:50:43