Esempio n. 1
0
 /// <summary>
 /// Bulk Insert with a given destination name
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="db"></param>
 /// <param name="tableName"></param>
 /// <param name="dt"></param>
 /// <param name="tran"></param>
 public static void BulkInsert <T>(this SqlConnection db, string tableName, List <T> dt, SqlTransaction tran = null)
 {
     using (var sbc = new SqlBulkInsert(db, tran))
     {
         sbc.BulkInsert(tableName, dt);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 批量插入数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="db"></param>
        /// <param name="dt"></param>
        public static void BulkInsert <T>(this SqlConnection db, List <T> dt)
        {
            var tableName = typeof(T).Name;

            using (var sbc = new SqlBulkInsert(db))
            {
                sbc.BulkInsert(tableName, dt);
            }
        }