/// <summary> /// Query Database with IStoredProcedure /// </summary> /// <param name="proc">Procedure</param> /// <returns>Data Set</returns> public virtual async Task<DataSet> Query(IStoredProcedure sproc) { if (null == sproc) { throw new ArgumentNullException("sproc"); } DataSet ds = null; using (var command = sproc.Build(this.connection)) { ds = await this.Query(command); } return ds; }
/// <summary> /// Non-Query /// </summary> /// <param name="sproc">Procedure To Execute</param> /// <returns>rows affected</returns> public virtual async Task<int> NonQuery(IStoredProcedure sproc) { if (null == sproc) { throw new ArgumentNullException("sproc"); } var rowsAffected = 0; using (var command = sproc.Build(this.connection)) { rowsAffected = await this.NonQuery(command); } return rowsAffected; }
/// <summary> /// Query for Reader with IStoredProcecure /// </summary> /// <param name="sproc">Stored Procedure</param> /// <returns>Data Reader</returns> public virtual async Task<IDataReader> DataReader(IStoredProcedure sproc) { if (null == sproc) { throw new ArgumentNullException("sproc"); } IDataReader reader; using (var command = sproc.Build(this.connection)) { if (this.connection.State != ConnectionState.Open) { await this.connection.OpenAsync(); } reader = await command.ExecuteReaderAsync(); } return reader; }