/// <summary> /// 批量数据导入。 /// </summary> /// <param name="args">参数。</param> public void BulkCopy(BulkCopyArguments args) { switch (this._Engine.Injector.Provider) { case DbEngineProvider.MicrosoftSqlServer: this.BulkCopyMSSQL(args); break; //case DbEngineProvider.Oracle: // this.BulkCopyOracle(args); // break; default: throw new NotSupportedException("当前数据提供程序不支持批量加载功能。"); } }
private void BulkCopyOracle(BulkCopyArguments args) { //DDTek.Oracle.OracleBulkCopy bulkCopy = new DDTek.Oracle.OracleBulkCopy(this._Connection as DDTek.Oracle.OracleConnection); //bulkCopy.BatchSize = args.BatchSize; //bulkCopy.BulkCopyTimeout = args.BulkCopyTimeout; //bulkCopy.DestinationTableName = args.DestinationTableName; //bulkCopy.NotifyAfter = args.NotifyAfter; //if(args.RowsCopied != null) //{ // bulkCopy.OracleRowsCopied += (ss, ee) => // { // ee.Abort = args.RowsCopied(ee.RowsCopied); // }; //} //bulkCopy.WriteToServer(args.Table, args.RowState); }
private void BulkCopyMSSQL(BulkCopyArguments args) { System.Data.SqlClient.SqlBulkCopy bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._Connection as System.Data.SqlClient.SqlConnection); bulkCopy.BatchSize = args.BatchSize; bulkCopy.BulkCopyTimeout = args.BulkCopyTimeout; bulkCopy.DestinationTableName = args.DestinationTableName; bulkCopy.NotifyAfter = args.NotifyAfter; if (args.RowsCopied != null) { bulkCopy.SqlRowsCopied += (ss, ee) => { ee.Abort = args.RowsCopied(ee.RowsCopied); }; } bulkCopy.WriteToServer(args.Table, args.RowState); }