Skip to content

Instantly share code, notes, and snippets.

View michal-ciechan's full-sized avatar

Michal Ciechan michal-ciechan

  • Maven
View GitHub Profile
public static class SqlBulkCopyEx
{
public static void BulkInsert<T>(string connectionString, IEnumerable<T> list, int batchSize = 0, string table = null)
{
using (var bulkCopy = new SqlBulkCopy(connectionString))
{
var type = typeof (T);
var tableName = type.Name;
var tableAttribute = (TableAttribute)type.GetCustomAttributes(typeof (TableAttribute), false).FirstOrDefault();