Esempio n. 1
0
 private void buildValueList(MatchResult result, ValueList values)
 {
     MatchResult multiple = result.Matches[SqlGrammar.ValueList.Multiple.Name];
     if (multiple.IsMatch)
     {
         MatchResult first = multiple.Matches[SqlGrammar.ValueList.Multiple.First];
         IProjectionItem value = (IProjectionItem)buildArithmeticItem(first);
         values.AddValue(value);
         MatchResult remaining = multiple.Matches[SqlGrammar.ValueList.Multiple.Remaining];
         buildValueList(remaining, values);
         return;
     }
     MatchResult single = result.Matches[SqlGrammar.ValueList.Single];
     if (single.IsMatch)
     {
         IProjectionItem value = (IProjectionItem)buildArithmeticItem(single);
         values.AddValue(value);
         return;
     }
     throw new NotImplementedException();
 }
Esempio n. 2
0
 public void TestInsert_MultipleColumns()
 {
     Table table = new Table("Table");
     ValueList values = new ValueList();
     InsertBuilder builder = new InsertBuilder(table, values);
     builder.AddColumn(builder.Table.Column("Column1"));
     builder.AddColumn(builder.Table.Column("Column2"));
     values.AddValue(new NumericLiteral(1));
     values.AddValue(new NullLiteral());
     Formatter formatter = new Formatter();
     string commandText = formatter.GetCommandText(builder, new CommandOptions() { AliasColumnSourcesUsingAs = true });
     string expected = "INSERT INTO Table (Column1, Column2) VALUES(1, NULL)";
     Assert.AreEqual(expected, commandText, "The wrong SQL was generated.");
 }