public IEnumerable <string> SimulateExecuteCommandText(SqlTableWithRecords records, CancellationToken token)
        {
            if (records.InsertOnlyMode == false)
            {
                // first, delete all the rows that might already exist there
                foreach (var deleteQuery in GenerateDeleteItemsCommandText(records.TableName, records.DocumentIdColumn, _configuration.ParameterizeDeletes,
                                                                           records.Deletes, token))
                {
                    yield return(deleteQuery);
                }
            }

            foreach (var insertQuery in GenerteInsertItemCommandText(records.TableName, records.DocumentIdColumn, records.Inserts, token))
            {
                yield return(insertQuery);
            }
        }
Пример #2
0
        public SqlWriteStats Write(SqlTableWithRecords table, List <DbCommand> commands, CancellationToken token)
        {
            var stats = new SqlWriteStats();

            var collectCommands = commands != null ? commands.Add : (Action <DbCommand>)null;

            if (table.InsertOnlyMode == false && table.Deletes.Count > 0)
            {
                // first, delete all the rows that might already exist there
                stats.DeletedRecordsCount = DeleteItems(table.TableName, table.DocumentIdColumn, _etl.Configuration.ParameterizeDeletes, table.Deletes, collectCommands, token);
            }

            if (table.Inserts.Count > 0)
            {
                stats.InsertedRecordsCount = InsertItems(table.TableName, table.DocumentIdColumn, table.Inserts, collectCommands, token);
            }

            return(stats);
        }