public IList<R> GetExternalResults(string con) {
using (DbContext tempContext = new DbContext(con)) {
return tempContext.Database.SqlQuery<R>("SELECT * FROM xx").ToList();
}
}
Parallel.ForEach(GetExternalResults(con), record => {
this.AddRow(record);
this.AddBulkRecords(record); // if batch > xx, then save the record using SQL Bulk Copy
});
public IList<R> GetExternalResults(string con) {
using (DbContext tempContext = new DbContext(con)) {
return tempContext.Database.SqlQuery<R>("SELECT * FROM xx").ToList();
}
}
Parallel.ForEach(GetExternalResults(con), record => {
this.AddRow(record);
this.AddBulkRecords(record); // if batch > xx, then save the record using SQL Bulk Copy
});