使用 TableAdapter 更新数据:性能不佳

Update Data Using a TableAdapter: bad performances

伪代码

var dsMaster = new DS_Master();
var el99TestTableAdapter = new EL_99_TESTTableAdapter();

Cycle 
    var el99TestRow = dsMaster.EL_99_TEST.NewEL_99_TESTRow();
    dsMaster.EL_99_TEST.Rows.Add(el99TestRow);
end Cycle

el99TestTableAdapter.Adapter.Update(dsMaster.EL_99_TEST);

这是一个经过测试的优秀解决方案:<5 秒 85000 行

private void BulkSaveCsvData(DataTable dt, string destinationTableName)
    {
        using (var bulkCopy = new SqlBulkCopy(_dbConnecion, SqlBulkCopyOptions.Default))
        {
            foreach (DataColumn col in dt.Columns)
            {
                bulkCopy.ColumnMappings.Add(col.ColumnName, col.ColumnName);
            }
            bulkCopy.BulkCopyTimeout = 600;
            bulkCopy.DestinationTableName = destinationTableName;
            bulkCopy.WriteToServer(dt);
        }
    }