I have a L2S query that looks like this:
using (MyDC TheDC = new MyDC())
{
foreach (MyObject TheObject in TheListOfMyObjects)
{
DBTable TheTable = new DBTable();
TheTable.Prop1 = TheObject.Prop1;
TheTable.Prop2 = TheObject.Prop2;
// only 2 properties, an int and a string
TheDC.DBTables.InsertOnSubmit(TheTable);
}
TheDC.SubmitChanges();
}
How could I change this to a stored procedure that does a bulk insert of the list? I found this article that talks about using a dataset and sqlbulkcopy classes; is this the best way to do it?
Thank you for your suggestions and feedback.
Maybe something like this: