I am using the dapper rainbow database.cs extensions,
private void insertList(IEnumerable<myObject> list)
{
using (SqlConnection conn = new SqlConnection(connectionString))
{
var db = myDB.Init(conn, commandTimeout: 100);
db.myTable.tableName = "ds.myTable";
Parallel.ForEach(dsList, a => db.myTableInsert(a)
);
db.Dispose();
}
}
This won't work, i think i need to open and close the connection inside the Parallel.ForEach. Is that the write way to do it?
I wanted to use this extension, its very helpful and hand, but having this problem of inserting a list. I could not find anything online about using this extension and using a list as well.