/// <summary>
 /// Returns a cold observable that compiles a SQL query with
 /// provided bind parameter values, that publishes the rows in the result
 /// set for each subscription.
 /// </summary>
 /// <param name="This">The asynchronous database connection.</param>
 /// <param name="query">The SQL query to compile and Query.</param>
 /// <param name="values">The bind parameter values.</param>
 /// <returns>A cold observable of rows in the result set.</returns>
 public static IObservable<IReadOnlyList<IResultSetValue>> Query(
     this IAsyncDatabaseConnection This, ISqlQuery query, params object[] values)
 {
     Contract.Requires(This != null);
     Contract.Requires(query != null);
     Contract.Requires(values != null);
     return This.Query(query.ToString(), values);
 }
Example #2
0
        /// <summary>
        /// Adds a subquery to the SELECT statement.
        /// </summary>
        /// <param name="expression">A subquery.</param>
        /// <returns>The query itself.</returns>
        public SqlQuery Select(ISqlQuery expression)
        {
            if (expression == null)
                throw new ArgumentNullException("expression");

            this.Select(expression.ToString());

            return this;
        }
Example #3
0
        /// <summary>
        /// Adds a subquery to the SELECT statement.
        /// </summary>
        /// <param name="expression">A subquery.</param>
        /// <param name="columnName">A column name</param>
        /// <returns>The query itself.</returns>
        public SqlQuery Select(ISqlQuery expression, string columnName)
        {
            if (expression == null)
                throw new ArgumentNullException("expression");

            if (string.IsNullOrEmpty(columnName))
                throw new ArgumentNullException("columnName");

            this.Select(expression.ToString(), columnName);

            return this;
        }
Example #4
0
        /// <summary>
        /// Adds a subquery to the FROM statement, with given short name.
        /// </summary>
        /// <param name="subQuery">A subquery</param>
        /// <param name="alias">Alias that contains the short name.</param>
        /// <returns>The query itself.</returns>
        /// <remarks>This overload requires that alias has a table name.</remarks>
        public SqlQuery From(ISqlQuery subQuery, IAlias alias)
        {
            if (subQuery == null)
                throw new ArgumentNullException("subQuery");

            if (alias == null)
                throw new ArgumentNullException("alias");

            return From(subQuery.ToString(), alias);
        }
 /// <summary>
 /// Compiles a SQL query, returning the an <see cref="IEnumerable&lt;T&gt;"/> of rows in the result set.
 /// </summary>
 /// <param name="This">The database connection.</param>
 /// <param name="query">The SQL statement to compile and Query.</param>
 /// <returns>An <see cref="IEnumerable&lt;T&gt;"/> of rows in the result set.</returns>
 public static IEnumerable<IReadOnlyList<IResultSetValue>> Query(this IDatabaseConnection This, ISqlQuery query)
 {
     Contract.Requires(This != null);
     Contract.Requires(query != null);
     return This.Query(query.ToString());
 }
Example #6
0
 /// <summary>
 ///   Belirtilen SqlQuery i içeren yeni bir 
 ///   kriter oluşturur.</summary>
 /// <param name="query">
 ///   Query nesnesi (genellikle sub query).</param>
 public Criteria(ISqlQuery query)
     : this(query.ToString())
 {
 }
 /// <summary>
 /// Compiles a SQL query.
 /// </summary>
 /// <param name="This">The database connection.</param>
 /// <param name="query">The SQL query to compile.</param>
 /// <returns>The compiled statement.</returns>
 public static IStatement PrepareStatement(this IDatabaseConnection This, ISqlQuery query)
 {
     Contract.Requires(This != null);
     Contract.Requires(query != null);
     return This.PrepareStatement(query.ToString());
 }
Example #8
0
 /// <summary>
 /// Returns a cold observable that compiles a SQL query
 /// that publishes the rows in the result set for each subscription.
 /// </summary>
 /// <param name="This">The asynchronous database connection.</param>
 /// <param name="query">The SQL query to compile and Query.</param>
 /// <returns>A cold observable of rows in the result set.</returns>
 public static IObservable <IReadOnlyList <ResultSetValue> > Query(this IAsyncDatabaseConnection This, ISqlQuery query)
 {
     Contract.Requires(This != null);
     Contract.Requires(query != null);
     return(This.Query(query.ToString()));
 }
Example #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Criteria"/> class containing
 /// a query's string representation.
 /// </summary>
 /// <param name="query">The query.</param>
 public Criteria(ISqlQuery query)
     : this(query.ToString())
 {
 }
Example #10
0
 /// <summary>
 /// Compiles a SQL query.
 /// </summary>
 /// <param name="This">The database connection.</param>
 /// <param name="query">The SQL query to compile.</param>
 /// <returns>The compiled statement.</returns>
 public static IStatement PrepareStatement(this IDatabaseConnection This, ISqlQuery query)
 {
     Contract.Requires(This != null);
     Contract.Requires(query != null);
     return(This.PrepareStatement(query.ToString()));
 }
Example #11
0
 /// <summary>
 /// Return a list of values, reader is closed after the call
 /// </summary>
 /// <typeparam name="TValue">The type of the value.</typeparam>
 /// <param name="cnn">Connection.</param>
 /// <param name="sql">SQL query.</param>
 /// <param name="transaction">The transaction.</param>
 /// <param name="buffered">if set to <c>true</c> results are buffered.</param>
 /// <param name="commandTimeout">The command timeout.</param>
 /// <param name="commandType">Type of the command.</param>
 /// <returns>List of values</returns>
 public static IEnumerable <TValue> Query <TValue>(this IDbConnection cnn, ISqlQuery sql, IDbTransaction transaction = null, bool buffered = true, int?commandTimeout = null, CommandType?commandType = null)
 {
     cnn.EnsureOpen();
     return(Dapper.SqlMapper.Query <TValue>(cnn, SqlHelper.FixCommandText(sql.ToString(), cnn.GetDialect()), sql.Params == null ? null : new DynamicParameters(sql.Params), null, buffered, commandTimeout, commandType));
 }
Example #12
0
        public DataSet ExecuteDatSet(ISqlQuery sqlQuery)
        {
            var strSql = sqlQuery.ToString();

            return(null);
        }
Example #13
0
        public DataTable ExecuteTableFunction(ISqlQuery sqlQuery)
        {
            var strSql = sqlQuery.ToString();

            return(null);
        }
		/// <summary>
		/// Preenche a tabela de dados especificada, com os critérios especificados.
		/// </summary>
		/// <param name="dataTable">O nome da tabela no DataSet que deverá ser preenchida.</param>
		/// <param name="query">A consulta de origem dos dados</param>
		public int FillData(string dataTable, ISqlQuery query)
		{
			string sql = null;
			try 
			{
#if DEBUG
				Debug.WriteLine("FillData");
				Debug.IndentLevel++;
				Debug.WriteLine("Data Table: " + dataTable);
				Debug.WriteLine("SQL: " + Regex.Replace(query.ToString().Replace(Environment.NewLine, " "), "\\s+", " "));
				Debug.IndentLevel--;
#endif
				sql = query.ToString();
				DataTable dt = ds.Tables[dataTable];
				if (dt != null)
					sql = Regex.Replace(sql, "FROM\\s+" + dataTable, "FROM " + GetPhysicalTableName(dt), RegexOptions.IgnoreCase);
			
				using (AdpConnection conn = CreateConnection()) 
				using (AdpDataAdapter da = new AdpDataAdapter())
				{
					da.SelectCommand = new AdpCommand(sql, conn);

					return da.Fill(ds, dataTable);
				}
			}
			catch (Exception ex)
			{
				if (sql == null)
					throw new ConnectorException("Erro ao realizar o preenchimento dos dados", ex);
				else
					throw ConnectorExceptionFactory.FromDatabaseException(ex, sql);
			}
		}