Пример #1
0
        /// <summary>
        /// Sets the identity column for the table.
        /// </summary>
        /// <param name="columnName"></param>
        /// <param name="direction"></param>
        /// <returns></returns>
        public QueryInsertReady <T> SetIdentityColumn(Expression <Func <T, object> > columnName, ColumnDirectionType direction)
        {
            var propertyName = BulkOperationsHelper.GetPropertyName(columnName);

            _outputIdentity = direction;

            if (propertyName == null)
            {
                throw new SqlBulkToolsException("SetIdentityColumn column name can't be null");
            }

            if (_identityColumn == null)
            {
                string actualPropertyName;

                if (_customColumnMappings.TryGetValue(propertyName, out actualPropertyName))
                {
                    _identityColumn = actualPropertyName;
                }

                else
                {
                    _identityColumn = propertyName;
                }
            }

            else
            {
                throw new SqlBulkToolsException("Can't have more than one identity column");
            }

            _columns.Add(propertyName);

            return(this);
        }
        /// <summary>
        /// Sets the identity column for the table.
        /// </summary>
        /// <param name="columnName"></param>
        /// <param name="direction"></param>
        /// <returns></returns>
        public SimpleInsertQueryReady <T> SetIdentityColumn(Expression <Func <T, object> > columnName, ColumnDirectionType direction)
        {
            var propertyName = BulkOperationsHelper.GetPropertyName(columnName);

            _outputIdentity = direction;

            if (propertyName == null)
            {
                throw new SqlBulkToolsException("SetIdentityColumn column name can't be null");
            }

            if (_identityColumn == null)
            {
                _identityColumn = propertyName;
            }


            else
            {
                throw new SqlBulkToolsException("Can't have more than one identity column");
            }

            _columns.Add(propertyName);

            return(this);
        }
Пример #3
0
        #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member

        /// <summary>
        ///
        /// </summary>
        /// <param name="list"></param>
        /// <param name="tableName"></param>
        /// <param name="schema"></param>
        /// <param name="columns"></param>
        /// <param name="disableIndexList"></param>
        /// <param name="disableAllIndexes"></param>
        /// <param name="customColumnMappings"></param>
        /// <param name="sqlTimeout"></param>
        /// <param name="bulkCopyTimeout"></param>
        /// <param name="bulkCopyEnableStreaming"></param>
        /// <param name="bulkCopyNotifyAfter"></param>
        /// <param name="bulkCopyBatchSize"></param>
        /// <param name="sqlBulkCopyOptions"></param>
        /// <param name="bulkCopyDelegates"></param>
        protected AbstractOperation(IEnumerable <T> list, string tableName, string schema, HashSet <string> columns,
                                    HashSet <string> disableIndexList, bool disableAllIndexes,
                                    Dictionary <string, string> customColumnMappings, int sqlTimeout, int bulkCopyTimeout,
                                    bool bulkCopyEnableStreaming,
                                    int?bulkCopyNotifyAfter, int?bulkCopyBatchSize, SqlBulkCopyOptions sqlBulkCopyOptions,
                                    IEnumerable <SqlRowsCopiedEventHandler> bulkCopyDelegates)
        {
            _list                    = list;
            _tableName               = tableName;
            _schema                  = schema;
            _columns                 = columns;
            _disableIndexList        = disableIndexList;
            _disableAllIndexes       = disableAllIndexes;
            _customColumnMappings    = customColumnMappings;
            _sqlTimeout              = sqlTimeout;
            _bulkCopyTimeout         = bulkCopyTimeout;
            _bulkCopyEnableStreaming = bulkCopyEnableStreaming;
            _bulkCopyNotifyAfter     = bulkCopyNotifyAfter;
            _bulkCopyBatchSize       = bulkCopyBatchSize;
            _sqlBulkCopyOptions      = sqlBulkCopyOptions;
            _identityColumn          = null;
            _collationColumnDic      = new Dictionary <string, string>();
            _outputIdentityDic       = new Dictionary <int, T>();
            _outputIdentity          = ColumnDirectionType.Input;
            _matchTargetOn           = new List <string>();
            _bulkCopyDelegates       = bulkCopyDelegates;
        }
Пример #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="singleEntity"></param>
 /// <param name="tableName"></param>
 /// <param name="schema"></param>
 /// <param name="columns"></param>
 /// <param name="customColumnMappings"></param>
 /// <param name="sqlParams"></param>
 public QueryInsertReady(T singleEntity, string tableName, string schema, HashSet <string> columns, Dictionary <string, string> customColumnMappings,
                         List <SqlParameter> sqlParams)
 {
     _singleEntity         = singleEntity;
     _tableName            = tableName;
     _schema               = schema;
     _columns              = columns;
     _customColumnMappings = customColumnMappings;
     _sqlParams            = sqlParams;
     _outputIdentity       = ColumnDirectionType.Input;
 }
Пример #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="singleEntity"></param>
 /// <param name="tableName"></param>
 /// <param name="schema"></param>
 /// <param name="columns"></param>
 /// <param name="customColumnMappings"></param>
 /// <param name="sqlParams"></param>
 public QueryUpsertReady(T singleEntity, string tableName, string schema, HashSet <string> columns, Dictionary <string, string> customColumnMappings,
                         List <SqlParameter> sqlParams)
 {
     _singleEntity         = singleEntity;
     _tableName            = tableName;
     _schema               = schema;
     _columns              = columns;
     _customColumnMappings = customColumnMappings;
     _sqlParams            = sqlParams;
     _matchTargetOnSet     = new HashSet <string>();
     _outputIdentity       = ColumnDirectionType.Input;
     _excludeFromUpdate    = new HashSet <string>();
     _collationColumnDic   = new Dictionary <string, string>();
 }
Пример #6
0
        #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member

        /// <summary>
        ///
        /// </summary>
        /// <param name="list"></param>
        /// <param name="tableName"></param>
        /// <param name="schema"></param>
        /// <param name="columns"></param>
        /// <param name="customColumnMappings"></param>
        /// <param name="bulkCopySettings"></param>
        protected AbstractOperation(IEnumerable <T> list, string tableName, string schema, HashSet <string> columns,
                                    Dictionary <string, string> customColumnMappings, BulkCopySettings bulkCopySettings)
        {
            _list                 = list;
            _tableName            = tableName;
            _schema               = schema;
            _columns              = columns;
            _disableAllIndexes    = false;
            _customColumnMappings = customColumnMappings;
            _identityColumn       = null;
            _collationColumnDic   = new Dictionary <string, string>();
            _outputIdentityDic    = new Dictionary <int, T>();
            _outputIdentity       = ColumnDirectionType.Input;
            _matchTargetOn        = new List <string>();
            _bulkCopySettings     = bulkCopySettings;
            _tableHint            = "HOLDLOCK";
        }
Пример #7
0
        /// <summary>
        /// Sets the identity column for the table.
        /// </summary>
        /// <param name="columnName"></param>
        /// <param name="outputIdentity"></param>
        /// <returns></returns>
        public QueryUpsertReady <T> SetIdentityColumn(Expression <Func <T, object> > columnName, ColumnDirectionType outputIdentity)
        {
            var propertyName = BulkOperationsHelper.GetPropertyName(columnName);

            _outputIdentity = outputIdentity;

            if (propertyName == null)
            {
                throw new SqlBulkToolsException("SetIdentityColumn column name can't be null");
            }

            if (_identityColumn == null)
            {
                _identityColumn = BulkOperationsHelper.GetActualColumn(_customColumnMappings, propertyName);
            }
            else
            {
                throw new SqlBulkToolsException("Can't have more than one identity column");
            }

            return(this);
        }
Пример #8
0
 /// <summary>
 /// Sets the identity column for the table. Required if an Identity column exists in table and one of the two
 /// following conditions is met: (1) MatchTargetOn list contains an identity column (2) AddAllColumns is used in setup.
 /// </summary>
 /// <param name="columnName"></param>
 /// <param name="outputIdentity"></param>
 /// <returns></returns>
 public BulkInsertOrUpdate <T> SetIdentityColumn(Expression <Func <T, object> > columnName, ColumnDirectionType outputIdentity)
 {
     base.SetIdentity(columnName, outputIdentity);
     return(this);
 }
Пример #9
0
 /// <summary>
 /// Sets the identity column for the table. Required if an Identity column exists in table and one of the two
 /// following conditions is met: (1) MatchTargetOn list contains an identity column (2) AddAllColumns is used in setup.
 /// </summary>
 /// <param name="columnName"></param>
 /// <param name="outputIdentity"></param>
 /// <returns></returns>
 public BulkUpdate <T> SetIdentityColumn(string columnName, ColumnDirectionType outputIdentity)
 {
     base.SetIdentity(columnName, outputIdentity);
     return(this);
 }
Пример #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="columnName"></param>
 /// <param name="outputIdentity"></param>
 protected void SetIdentity(Expression <Func <T, object> > columnName, ColumnDirectionType outputIdentity)
 {
     _outputIdentity = outputIdentity;
     SetIdentity(columnName);
 }
Пример #11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="columnName"></param>
 /// <param name="outputIdentity"></param>
 protected void SetIdentity(string columnName, ColumnDirectionType outputIdentity)
 {
     _outputIdentity = outputIdentity;
     SetIdentity(columnName);
 }
Пример #12
0
 /// <summary>
 /// Sets the identity column for the table. Required if an Identity column exists in table and one of the two
 /// following conditions is met: (1) MatchTargetOn list contains an identity column (2) AddAllColumns is used in setup.
 /// </summary>
 /// <param name="columnName"></param>
 /// <param name="outputIdentity"></param>
 /// <returns></returns>
 public BulkDelete <T> SetIdentityColumn(Expression <Func <T, object> > columnName, ColumnDirectionType outputIdentity)
 {
     SetIdentity(columnName, outputIdentity);
     return(this);
 }