コード例 #1
0
        /// <summary>
        /// The get reader.
        /// </summary>
        /// <param name="dbAccess">
        /// The db access.
        /// </param>
        /// <param name="cmd">
        /// The cmd.
        /// </param>
        /// <param name="dbTransaction">
        /// The db transaction.
        /// </param>
        /// <returns>
        /// The <see cref="IDataReader"/> .
        /// </returns>
        public static IDataReader GetReader([NotNull] this IDbAccessV2 dbAccess, [NotNull] IDbCommand cmd, [NotNull] IDbTransaction dbTransaction)
        {
            CodeContracts.ArgumentNotNull(dbAccess, "dbAccess");
            CodeContracts.ArgumentNotNull(cmd, "cmd");
            CodeContracts.ArgumentNotNull(dbTransaction, "dbTransaction");

            return(dbAccess.Execute((c) => c.ExecuteReader(), cmd, dbTransaction));
        }
コード例 #2
0
        /// <summary>
        /// The execute scalar.
        /// </summary>
        /// <param name="dbAccess">
        /// The db access.
        /// </param>
        /// <param name="cmd">
        /// The cmd.
        /// </param>
        /// <param name="dbTransaction">
        /// The db Transaction.
        /// </param>
        /// <returns>
        /// The execute scalar.
        /// </returns>
        public static object ExecuteScalar(
            [NotNull] this IDbAccessV2 dbAccess, [NotNull] IDbCommand cmd, [CanBeNull] IDbTransaction dbTransaction = null)
        {
            CodeContracts.ArgumentNotNull(dbAccess, "dbAccess");
            CodeContracts.ArgumentNotNull(cmd, "cmd");

            return(dbAccess.Execute((c) => c.ExecuteScalar(), cmd, dbTransaction));
        }
コード例 #3
0
        /// <summary>
        /// The get dataset.
        /// </summary>
        /// <param name="dbAccess">
        /// The db access.
        /// </param>
        /// <param name="cmd">
        /// The cmd.
        /// </param>
        /// <param name="dbTransaction">
        /// </param>
        /// <returns>
        /// The <see cref="DataSet"/> .
        /// </returns>
        public static DataSet GetDataset([NotNull] this IDbAccessV2 dbAccess, [NotNull] IDbCommand cmd, [CanBeNull] IDbTransaction dbTransaction = null)
        {
            CodeContracts.ArgumentNotNull(dbAccess, "dbAccess");
            CodeContracts.ArgumentNotNull(cmd, "cmd");

            return(dbAccess.Execute(
                       (c) =>
            {
                var ds = new DataSet();

                IDbDataAdapter dataAdapter = dbAccess.DbProviderFactory.CreateDataAdapter();

                if (dataAdapter != null)
                {
                    dataAdapter.SelectCommand = cmd;
                    dataAdapter.Fill(ds);
                }

                return ds;
            },
                       cmd,
                       dbTransaction));
        }