Skip to content

Instantly share code, notes, and snippets.

@ronnieoverby
Last active December 13, 2015 20:28
Show Gist options
  • Select an option

  • Save ronnieoverby/4969630 to your computer and use it in GitHub Desktop.

Select an option

Save ronnieoverby/4969630 to your computer and use it in GitHub Desktop.
static void OtherInsertOverloadExample(BulkInserter<Person> bulkInserter, IEnumerable<Person> people)
{
// sql connection is being managed externally
foreach (var person in people)
{
// contrived example... do some work on each person
person.Salary = DetermineSalary(person);
// this will add the object to a list managed by BulkInserter<T>
// the data will not be written to the database until the list count == batch size
bulkInserter.Insert(person);
}
// the list probably has some more
// people that haven't been inserted
// send remnant people to the database
bulkInserter.Flush();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment