示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SqlSubquery"/> class using the
        /// specified <paramref name="query"/> and <paramref name="alias"/>.
        /// </summary>
        /// <param name="query">
        /// The <see cref="SqlSelect"/> query to use as an expression.
        /// </param>
        /// <param name="alias">
        /// The alias used for the subquery.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Thrown when the <paramref name="query"/> or <paramref name="alias"/> argument is
        /// <see langword="null"/>.
        /// </exception>
        public SqlSubquery(ISqlGo<SqlSelect> query, string alias)
            : base(alias)
        {
            if (query == null) throw new ArgumentNullException(nameof(query));

            Query = query.Go();
        }
示例#2
0
 /// <summary>
 /// Converts the specified SQL expression tree builder to an <see cref="IDbCommand"/>
 /// instance for the specified <paramref name="connection" />.
 /// </summary>
 /// <param name="sql">
 /// The SQL expression tree builder 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 SQL expression tree builder are
 /// automatically converted to <see cref="IDbDataParameter"/> instances and attached to
 /// the returned <see cref="IDbCommand"/>.
 /// </remarks>
 public static IDbCommand ToCommand <T>(this ISqlGo <T> sql, IDbConnection connection)
     where T : SqlStatement
 {
     if (sql == null)
     {
         throw new ArgumentNullException(nameof(sql));
     }
     return(connection.CreateCommandInternal(sql.Go()));
 }
示例#3
0
 /// <summary>
 /// Converts the specified SQL expression tree builder to SQL text.
 /// </summary>
 /// <typeparam name="T">
 /// The type of SQL statement the SQL expression tree builder creates.
 /// </typeparam>
 /// <param name="sql">
 /// An expression tree builder representing a SQL statement.
 /// </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 builder.
 /// </returns>
 public static string ToSql <T>(this ISqlGo <T> sql, SqlDialect dialect, Action <SqlParameter> parameterCallback)
     where T : SqlStatement
 {
     if (sql == null)
     {
         throw new ArgumentNullException(nameof(sql));
     }
     return(sql.Go().ToSqlInternal(dialect, parameterCallback));
 }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SqlSubquery"/> class using the
        /// specified <paramref name="query"/> and <paramref name="alias"/>.
        /// </summary>
        /// <param name="query">
        /// The <see cref="SqlSelect"/> query to use as an expression.
        /// </param>
        /// <param name="alias">
        /// The alias used for the subquery.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Thrown when the <paramref name="query"/> or <paramref name="alias"/> argument is
        /// <see langword="null"/>.
        /// </exception>
        public SqlSubquery(ISqlGo <SqlSelect> query, string alias)
            : base(alias)
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }

            Query = query.Go();
        }