Skip to content

Instantly share code, notes, and snippets.

@jferguson
jferguson / gist:1681480
Created January 26, 2012 07:12
SqlBulkCopy Generic List<T>
public static void BulkInsert<T>(string connection, string tableName, IList<T> list)
{
using (var bulkCopy = new SqlBulkCopy(connection))
{
bulkCopy.BatchSize = list.Count;
bulkCopy.DestinationTableName = tableName;
var table = new DataTable();
var props = TypeDescriptor.GetProperties(typeof(T))
//Dirty hack to make sure we only have system data types