Пример #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());
        }
Пример #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());
        }
Пример #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());
        }
Пример #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);
     }
 }
Пример #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));
 }
Пример #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);
		}
Пример #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));
 }
Пример #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)));
 }
Пример #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));
 }
Пример #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));
 }
Пример #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();
		}
Пример #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();
		}
Пример #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();
		}
Пример #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);
		}