Example #1
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>
        /// <typeparam name="T"></typeparam>
        /// <param name="db"></param>
        /// <param name="sprocName">Name of the stored procedure to call.</param>
        /// <param name="parameters">An object that contains the properties to add as SQL parameters to the SQL command.</param>
        /// <param name="dflt"></param>
        /// <returns></returns>
        public static T ExecuteScalar <T>(this BaDatabase db, string sprocName, object parameters = null, T dflt = default(T))
        {
            var cmd = db.PrepareSprocCmd(sprocName, parameters);

            return(db.ExecuteScalar(cmd, dflt));
        }
Example #2
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="db"></param>
        /// <param name="sprocName">Name of the stored procedure to call.</param>
        /// <param name="parameters">An object that contains the properties to add as SQL parameters to the SQL command.</param>
        /// <param name="dflt"></param>
        /// <returns></returns>
        public static object ExecuteScalar(this BaDatabase db, string sprocName, object parameters = null, object dflt = null)
        {
            var cmd = db.PrepareSprocCmd(sprocName, parameters);

            return(db.ExecuteScalar(cmd, dflt));
        }