コード例 #1
0
 public void TestDelete_AliasedTable_WithAs()
 {
     Table table = new Table("Table");
     DeleteBuilder builder = new DeleteBuilder(table, "t");
     Formatter formatter = new Formatter();
     string commandText = formatter.GetCommandText(builder, new CommandOptions() { AliasColumnSourcesUsingAs = true });
     string expected = "DELETE FROM Table AS t";
     Assert.AreEqual(expected, commandText, "The wrong SQL was generated.");
 }
コード例 #2
0
 public void TestDelete_AliasedTable()
 {
     Table table = new Table("Table");
     DeleteBuilder builder = new DeleteBuilder(table, "t");
     Formatter formatter = new Formatter();
     string commandText = formatter.GetCommandText(builder);
     string expected = "DELETE FROM Table t";
     Assert.AreEqual(expected, commandText, "The wrong SQL was generated.");
 }
コード例 #3
0
 public void TestDelete_Where()
 {
     Table table = new Table("Table");
     DeleteBuilder builder = new DeleteBuilder(table);
     builder.AddWhere(new EqualToFilter(builder.Table.Column("Column"), new NumericLiteral(1)));
     Formatter formatter = new Formatter();
     string commandText = formatter.GetCommandText(builder);
     string expected = "DELETE FROM Table WHERE Column = 1";
     Assert.AreEqual(expected, commandText, "The wrong SQL was generated.");
 }
コード例 #4
0
 /// <summary>
 /// Generates the text for a Delete builder.
 /// </summary>
 /// <param name="item">The Delete builder to generate the text for.</param>
 protected internal override void VisitDelete(DeleteBuilder item)
 {
     forCommandType(CommandType.Delete).visitDelete(item);
 }
コード例 #5
0
 private void visitDelete(DeleteBuilder item)
 {
     writer.Write("DELETE ");
     if (options.VerboseDeleteStatement)
     {
         writer.Write("FROM ");
     }
     forSourceContext(SourceReferenceType.Declaration).visitAliasedSource(item.Table);
     if (item.WhereFilterGroup.HasFilters)
     {
         writer.Write(" WHERE ");
         IFilter filterGroup = item.WhereFilterGroup;
         filterGroup.Accept(forSubCommand().forValueContext(ValueReferenceType.Reference));
     }
 }
コード例 #6
0
 /// <summary>
 /// Visits a Delete builder.
 /// </summary>
 /// <param name="item">The item to visit.</param>
 protected internal virtual void VisitDelete(DeleteBuilder item)
 {
 }
コード例 #7
0
 private ICommand buildDeleteStatement(MatchResult result)
 {
     MatchResult tableResult = result.Matches[SqlGrammar.DeleteStatement.Table];
     Table table = buildTable(tableResult);
     string alias = null;
     MatchResult aliasExpressionResult = result.Matches[SqlGrammar.DeleteStatement.AliasExpression.Name];
     if (aliasExpressionResult.IsMatch)
     {
         MatchResult aliasResult = aliasExpressionResult.Matches[SqlGrammar.DeleteStatement.AliasExpression.Alias];
         alias = getToken(aliasResult);
     }
     DeleteBuilder builder = new DeleteBuilder(table, alias);
     SourceCollection collection = new SourceCollection();
     collection.AddSource(builder.Table.GetSourceName(), builder.Table);
     scope.Push(collection);
     MatchResult whereResult = result.Matches[SqlGrammar.DeleteStatement.Where.Name];
     if (whereResult.IsMatch)
     {
         MatchResult filterListResult = whereResult.Matches[SqlGrammar.DeleteStatement.Where.FilterList];
         IFilter innerFilter = buildOrFilter(filterListResult);
         builder.WhereFilterGroup.AddFilter(innerFilter);
         builder.WhereFilterGroup.Optimize();
     }
     scope.Pop();
     return builder;
 }
コード例 #8
0
 protected override void VisitDelete(DeleteBuilder item)
 {
     var visitor = new DeleteRequestBuilderVisitor(Parameters, CrmMetadataProvider, TypeProvider, Settings);
     IVisitableBuilder visitable = item;
     visitable.Accept(visitor);
     SetOperation(visitor.GetCommand());
 }
コード例 #9
0
 /// <summary>
 /// Visits a Delete builder.
 /// </summary>
 /// <param name="item">The item to visit.</param>
 protected internal virtual void VisitDelete(DeleteBuilder item)
 {
 }