This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |