Пример #1
0
        public void Insert(DbConnection conn, string tableName, DataTable sourceData, Dictionary<string, string> columnMappings = null, DataRowState state = DataRowState.Added)
        {
            OracleConnection oracleConn = conn as OracleConnection;
            Check(oracleConn);

            using (OracleBulkCopyWrapper sqlBC = new OracleBulkCopyWrapper(oracleConn))
            {
                sqlBC.BatchSize = 10000;
                sqlBC.BulkCopyTimeout = 1200;
                sqlBC.DestinationTableName = tableName;
                if (columnMappings != null && columnMappings.Count > 0)
                {
                    foreach (var item in columnMappings)
                    {
                        sqlBC.ColumnMappings.Add(item.Value, item.Key);
                    }
                }
                else
                {
                    foreach (var item in sourceData.Columns.Cast<DataColumn>())
                    {
                        sqlBC.ColumnMappings.Add(item.ColumnName, item.ColumnName);
                    }

                }
                sqlBC.WriteToServer(sourceData, state);
            }
        }
Пример #2
0
        public void Insert(DbConnection conn, string tableName, DataTable sourceData, Dictionary <string, string> columnMappings = null, DataRowState state = DataRowState.Added)
        {
            OracleConnection oracleConn = conn as OracleConnection;

            Check(oracleConn);

            using (OracleBulkCopyWrapper sqlBC = new OracleBulkCopyWrapper(oracleConn))
            {
                sqlBC.BatchSize            = 10000;
                sqlBC.BulkCopyTimeout      = 1200;
                sqlBC.DestinationTableName = tableName;
                if (columnMappings != null && columnMappings.Count > 0)
                {
                    foreach (var item in columnMappings)
                    {
                        sqlBC.ColumnMappings.Add(item.Value, item.Key);
                    }
                }
                else
                {
                    foreach (var item in sourceData.Columns.Cast <DataColumn>())
                    {
                        sqlBC.ColumnMappings.Add(item.ColumnName, item.ColumnName);
                    }
                }
                sqlBC.WriteToServer(sourceData, state);
            }
        }