Beispiel #1
0
        /// <summary>
        /// Executes the CommandText against the Connection and builds an IDataReader.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <returns>An IDataReader object.</returns>
        public virtual IDataReader ExecuteReader(APSqlCommand command)
        {
            DbCommand dbCmd = _provider.BuildCommand(command);

            dbCmd.Connection  = Connection;
            dbCmd.Transaction = _transaction;
            return(dbCmd.ExecuteReader());
        }
Beispiel #2
0
        /// <summary>
        /// Executes an SQL statement against the Connection and returns the number of rows affected.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <returns>The number of rows affected.</returns>
        public virtual int ExecuteNonQuery(APSqlCommand command)
        {
            DbCommand dbCmd = _provider.BuildCommand(command);

            dbCmd.Connection  = Connection;
            dbCmd.Transaction = _transaction;
            return(dbCmd.ExecuteNonQuery());
        }
Beispiel #3
0
        /// <summary>
        /// Executes the query, and returns the first column of the first row in the result set returned
        /// by the query. Additional columns or rows are ignored.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
        public virtual object ExecuteScalar(APSqlCommand command)
        {
            if (command is APSqlInsertCommand)
            {
                (command as APSqlInsertCommand).NeedReturnAutoIncrement = true;
            }
            DbCommand dbCmd = _provider.BuildCommand(command);

            dbCmd.Connection  = Connection;
            dbCmd.Transaction = _transaction;
            return(dbCmd.ExecuteScalar());
        }
Beispiel #4
0
 /// <summary>
 /// Build command.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <returns>The DbCommand.</returns>
 public DbCommand BuildCommand(APSqlCommand command)
 {
     if (command is APSqlSelectCommand)
     {
         return(BuildSelectCommand(command as APSqlSelectCommand));
     }
     else if (command is APSqlDeleteCommand)
     {
         return(BuildDeleteCommand(command as APSqlDeleteCommand));
     }
     else if (command is APSqlUpdateCommand)
     {
         return(BuildUpdateCommand(command as APSqlUpdateCommand));
     }
     else if (command is APSqlInsertCommand)
     {
         return(BuildInsertCommand(command as APSqlInsertCommand));
     }
     else
     {
         throw new APDataException(APResource.APData_UnknownQueryCommand);
     }
 }
Beispiel #5
0
 /// <summary>
 /// Build condition phrase of 'NOT IN'.
 /// </summary>
 /// <param name="subQuery">Sub query.</param>
 /// <returns>Condition phrase of 'NOT IN'.</returns>
 public APSqlConditionPhrase NotIn(APSqlCommand subQuery)
 {
     return(new APSqlConditionPhrase(this, APSqlConditionOperator.NotIn, subQuery));
 }
Beispiel #6
0
		/// <summary>
		/// Build condition phrase of 'NOT IN'.
		/// </summary>
		/// <param name="subQuery">Sub query.</param>
		/// <returns>Condition phrase of 'NOT IN'.</returns>
		public APSqlConditionPhrase NotIn(APSqlCommand subQuery)
		{
			return new APSqlConditionPhrase(this, APSqlConditionOperator.NotIn, subQuery);
		}
Beispiel #7
0
 /// <summary>
 /// Executes the CommandText against the Connection and builds an IDataReader.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <returns>An IDataReader object.</returns>
 protected IDataReader ExecuteReader(APSqlCommand command)
 {
     return(_database.ExecuteReader(command));
 }
Beispiel #8
0
 /// <summary>
 /// Convert return value of ExecuteScalar to int type.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <returns>The count of query execute.</returns>
 protected int ExecuteCount(APSqlCommand command)
 {
     return(Convert.ToInt32(ExecuteScalar(command)));
 }
Beispiel #9
0
 /// <summary>
 /// Executes the query, and returns the first column of the first row in the result set
 /// returned by the query. Additional columns or rows are ignored.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <returns>The first column of the first row in the result set, or a null reference if
 /// the result set is empty.</returns>
 protected object ExecuteScalar(APSqlCommand command)
 {
     return(_database.ExecuteScalar(command));
 }
Beispiel #10
0
 /// <summary>
 /// Executes an SQL statement against the Connection and returns the number of rows affected.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <returns>The number of rows affected.</returns>
 protected int ExecuteNonQuery(APSqlCommand command)
 {
     return(_database.ExecuteNonQuery(command));
 }
Beispiel #11
0
		/// <summary>
		/// Executes the CommandText against the Connection and builds an IDataReader.
		/// </summary>
		/// <param name="command">The command.</param>
		/// <returns>An IDataReader object.</returns>
		public virtual IDataReader ExecuteReader(APSqlCommand command)
		{
			DbCommand dbCmd = _provider.BuildCommand(command);
			dbCmd.Connection = Connection;
			dbCmd.Transaction = _transaction;
			return dbCmd.ExecuteReader();
		}
Beispiel #12
0
		/// <summary>
		/// Executes the query, and returns the first column of the first row in the result set returned
		/// by the query. Additional columns or rows are ignored.
		/// </summary>
		/// <param name="command">The command.</param>
		/// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
		public virtual object ExecuteScalar(APSqlCommand command)
		{
			if (command is APSqlInsertCommand)
				(command as APSqlInsertCommand).NeedReturnAutoIncrement = true;
			DbCommand dbCmd = _provider.BuildCommand(command);
			dbCmd.Connection = Connection;
			dbCmd.Transaction = _transaction;
			return dbCmd.ExecuteScalar();
		}
Beispiel #13
0
		/// <summary>
		/// Executes an SQL statement against the Connection and returns the number of rows affected.
		/// </summary>
		/// <param name="command">The command.</param>
		/// <returns>The number of rows affected.</returns>
		public virtual int ExecuteNonQuery(APSqlCommand command)
		{
			DbCommand dbCmd = _provider.BuildCommand(command);
			dbCmd.Connection = Connection;
			dbCmd.Transaction = _transaction;
			return dbCmd.ExecuteNonQuery();
		}
Beispiel #14
0
		/// <summary>
		/// Build command.
		/// </summary>
		/// <param name="command">The command.</param>
		/// <returns>The DbCommand.</returns>
		public DbCommand BuildCommand(APSqlCommand command)
		{
			if (command is APSqlSelectCommand)
				return BuildSelectCommand(command as APSqlSelectCommand);
			else if (command is APSqlDeleteCommand)
				return BuildDeleteCommand(command as APSqlDeleteCommand);
			else if (command is APSqlUpdateCommand)
				return BuildUpdateCommand(command as APSqlUpdateCommand);
			else if (command is APSqlInsertCommand)
				return BuildInsertCommand(command as APSqlInsertCommand);
			else
				throw new APDataException(APResource.APData_UnknownQueryCommand);
		}