public DapperBulkUpdateOperation(AbstractConnection connection, Entity entity) {
            _connection = connection;
            _tflBatchId = entity.TflBatchId;
            _fields = entity.OutputFields();
            var writer = new FieldSqlWriter(_fields);
            var sets = writer.Alias(_connection.L, _connection.R).SetParam().Write(", ", false);

            _sql = string.Format(@"UPDATE [{0}] SET {1}, TflBatchId = @TflBatchId WHERE TflKey = @TflKey;", entity.OutputName(), sets);
        }
Ejemplo n.º 2
0
        protected override void PrepareCommand(Row row, SqlCommand command) {

            var sets = new FieldSqlWriter(_process.CalculatedFields.WithOutput())
                .Alias(_process.OutputConnection.L, _process.OutputConnection.R)
                .SetParam()
                .Write();

            command.CommandText = string.Format("UPDATE {0} SET {1} WHERE TflKey = @TflKey;", _process.MasterEntity.OutputName(), sets);
            foreach (var field in _process.CalculatedFields) {
                AddParameter(command, field.Identifier, row[field.Alias]);
            }
            AddParameter(command, "TflKey", row["TflKey"]);
        }
Ejemplo n.º 3
0
 public SqlResultsLoad(Process process) {
     _process = process;
     _fields = _process.CalculatedFields;
     var sets = new FieldSqlWriter(_fields).Alias(_process.OutputConnection.L, _process.OutputConnection.R).SetParam().Write();
     _sql = string.Format("UPDATE {0} SET {1} WHERE TflKey = @TflKey;", _process.MasterEntity.OutputName(), sets);
 }
Ejemplo n.º 4
0
 public void TestWriteNameIsNullAsAlias() {
     const string expected = "ISNULL([f1], 'x') AS [Field1], ISNULL([f2], 0) AS [Field2]";
     var actual = new FieldSqlWriter(_fields).Name("[", "]").IsNull().AsAlias("[", "]").Write();
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 5
0
 public void TestWriteNameDataTypeNull() {
     const string expected = "[f1] NVARCHAR(10) NULL, [f2] INT NULL";
     var actual = new FieldSqlWriter(_fields).Name("[", "]").DataType(new SqlServerDataTypeService()).Append(" NULL").Write();
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 6
0
 public void TestWriteName() {
     const string expected = "[f1], [f2]";
     var actual = new FieldSqlWriter(_fields).Name("[", "]").Write();
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 7
0
 public void TestWriteAliasIsNull() {
     const string expected = "ISNULL([Field1], 'x'), ISNULL([Field2], 0)";
     var actual = new FieldSqlWriter(_fields).Alias("[", "]").IsNull().Write();
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 8
0
        public void TestWriteAlias() {

            const string expected = "[Field1], [Field2]";
            var actual = new FieldSqlWriter(_fields).Alias("[","]").Write();
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 9
0
 public void TestWriteNothing() {
     const string expected = ", ";
     var actual = new FieldSqlWriter(_fields).Write();
     Assert.AreEqual(expected, actual);
 }