Пример #1
0
        public void Prepare(WriteToSqlMutator process, DetailedDbTableDefinition tableDefinition)
        {
            _tableDefinition = tableDefinition;

            _allDbColumns          = string.Join(", ", _tableDefinition.Columns.Select(x => x.DbColumn));
            _keyDbColumns          = string.Join(" AND ", _tableDefinition.Columns.Where(x => x.IsKey).Select(x => "target." + x.DbColumn + " = source." + x.DbColumn));
            _updateDbColumns       = string.Join(",\n\t\t", _tableDefinition.Columns.Where(x => !x.IsKey).Select(x => x.DbColumn + " = source." + x.DbColumn));
            _insertDbColumnsTarget = string.Join(", ", _tableDefinition.Columns.Where(x => x.Insert).Select(x => x.DbColumn));
            _insertDbColumnsSource = string.Join(", ", _tableDefinition.Columns.Where(x => x.Insert).Select(x => "source." + x.DbColumn));
        }
Пример #2
0
        public string CreateRowStatement(NamedConnectionString connectionString, IReadOnlySlimRow row, WriteToSqlMutator operation)
        {
            var startIndex = operation.ParameterCount;

            foreach (var column in _tableDefinition.Columns)
            {
                operation.CreateParameter(column, row[column.RowColumn]);
            }

            var statement = "(" + string.Join(", ", _tableDefinition.Columns.Select(_ => "@" + startIndex++.ToString("D", CultureInfo.InvariantCulture))) + ")";

            return(statement);
        }
Пример #3
0
 public void Prepare(WriteToSqlMutator process, DetailedDbTableDefinition tableDefinition)
 {
     _tableDefinition = tableDefinition;
     _columns         = _tableDefinition.Columns.Where(x => x.Insert).ToArray();
     _dbColumns       = string.Join(", ", _columns.Select(x => x.DbColumn));
 }