Esempio n. 1
0
 public override void Visit(SqlUnion expression)
 {
     expression.Statements.For(
         (index, statement) =>
     {
         if (index > 0)
         {
             _writer.WriteKeyword(SqlKeywords.Union);
         }
         _writer.WriteOpenParenthesis();
         statement.Accept(this);
         _writer.WriteCloseParenthesis();
     });
 }
Esempio n. 2
0
 /// <summary>
 /// Converts the specified <see cref="SqlUnion"/> expression tree to an <see cref="IDbCommand"/>
 /// instance for the specified <paramref name="connection" />.
 /// </summary>
 /// <param name="sql">
 /// The <see cref="SqlSelect"/> to convert to an <see cref="IDbCommand"/>.
 /// </param>
 /// <param name="connection">
 /// The <see cref="IDbConnection"/> for which to create an <see cref="IDbCommand"/>.
 /// </param>
 /// <returns>
 /// An <see cref="IDbCommand"/> for the specified <paramref name="connection"/> that reprents
 /// the specified SQL expression tree.
 /// </returns>
 /// <remarks>
 /// Any <see cref="SqlParameter"/> members of the <see cref="SqlSelect"/> expression are
 /// automatically converted to <see cref="IDbDataParameter"/> instances and attached to
 /// the returned <see cref="IDbCommand"/>.
 /// </remarks>
 public static IDbCommand ToCommand(this SqlUnion sql, IDbConnection connection)
 {
     return(connection.CreateCommandInternal(sql));
 }
Esempio n. 3
0
 /// <summary>
 /// Converts the specified <see cref="SqlUnion"/> expression tree to SQL text.
 /// </summary>
 /// <param name="sql">
 /// The <see cref="SqlUnion"/> to convert to SQL text.
 /// </param>
 /// <param name="dialect">
 /// The <see cref="SqlDialect"/> used to format the SQL text.
 /// </param>
 /// <param name="parameterCallback">
 /// A delegate that is called when a SQL parameter is encountered while converting the SQL expression.
 /// </param>
 /// <returns>
 /// The SQL text for the specified SQL expression tree.
 /// </returns>
 public static string ToSql(this SqlUnion sql, SqlDialect dialect, Action <SqlParameter> parameterCallback)
 {
     return(sql.ToSqlInternal(dialect, parameterCallback));
 }
Esempio n. 4
0
 /// <summary>
 /// Converts the specified <see cref="SqlUnion"/> expression tree to SQL text.
 /// </summary>
 /// <param name="sql">
 /// The <see cref="SqlUnion"/> to convert to SQL text.
 /// </param>
 /// <param name="dialect">
 /// The <see cref="SqlDialect"/> used to format the SQL text.
 /// </param>
 /// <returns>
 /// The SQL text for the specified SQL expression tree.
 /// </returns>
 public static string ToSql(this SqlUnion sql, SqlDialect dialect)
 {
     return(sql.ToSqlInternal(dialect));
 }
Esempio n. 5
0
 /// <summary>
 /// Converts the specified <see cref="SqlUnion"/> expression tree to SQL text.
 /// </summary>
 /// <param name="sql">
 /// The <see cref="SqlUnion"/> to convert to SQL text.
 /// </param>
 /// <param name="parameterCallback">
 /// A delegate that is called when a SQL parameter is encountered while converting the SQL expression.
 /// </param>
 /// <returns>
 /// The SQL text for the specified SQL expression tree.
 /// </returns>
 public static string ToSql(this SqlUnion sql, Action <SqlParameter> parameterCallback)
 {
     return(sql.ToSql(null, parameterCallback));
 }
Esempio n. 6
0
 /// <summary>
 /// Converts the specified <see cref="SqlUnion"/> expression tree to SQL text.
 /// </summary>
 /// <param name="sql">
 /// The <see cref="SqlUnion"/> to convert to SQL text.
 /// </param>
 /// <returns>
 /// The SQL text for the specified SQL expression tree.
 /// </returns>
 public static string ToSql(this SqlUnion sql)
 {
     return(sql.ToSql(null, null));
 }
 protected override SqlExpression VisitUnion(SqlUnion expression)
 {
     bool writeUnion = false;
     foreach (SqlSelect statement in expression.Statements)
     {
         if (writeUnion)
         {
             _writer.WriteUnion();
         }
         _writer.WriteOpenParenthesis();
         Visit(statement);
         _writer.WriteCloseParenthesis();
         writeUnion = true;
     }
     return expression;
 }
 /// <summary>
 /// Converts the specified <see cref="SqlUnion"/> expression tree to an <see cref="IDbCommand"/>
 /// instance for the specified <paramref name="connection" />.
 /// </summary>
 /// <param name="sql">
 /// The <see cref="SqlUnion"/> to convert to an <see cref="IDbCommand"/>.
 /// </param>
 /// <param name="connection">
 /// The <see cref="IDbConnection"/> for which to create an <see cref="IDbCommand"/>.
 /// </param>
 /// <returns>
 /// An <see cref="IDbCommand"/> for the specified <paramref name="connection"/> that reprents
 /// the specified SQL expression tree.
 /// </returns>
 /// <remarks>
 /// Any <see cref="SqlParameter"/> members of the <see cref="SqlUnion"/> expression are
 /// automatically converted to <see cref="IDbDataParameter"/> instances and attached to
 /// the returned <see cref="IDbCommand"/>.
 /// </remarks>
 public static IDbCommand CreateCommand(this IDbConnection connection, SqlUnion sql)
 {
     return connection.CreateCommandInternal(sql);
 }