Consider your List: IList<Customer> foo;
Using LINQ To SQL
Create a LINQ To SQL datacontext, and it's something like this:
using (var db = new CustomerDataContext())
{
db.Customer.InsertAllOnSubmit(foo);
db.SubmitChanges();
}
if you are using normal queries just write the stored procedure it would be a nice option
Using Stored Procedures
using (var conn = new SqlConnection())
{
using (var cmd = new SqlCommand(conn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "InsertCustomer";
foreach (Customer c in foo)
{
cmd.Parameters.Clear();
cmd.Parameters.Add(new SqlParameter("@CustomerName", c.Name);
conn.Open(dbConnString);
cmd.ExecuteNonQuery();
conn.Close();
}
}
}