Esempio n. 1
0
        /// <summary>
        /// Generic Typed version of calling a stored procedure
        /// </summary>
        /// <typeparam name="T">Type of object containing the parameter data</typeparam>
        /// <param name="context">Database Context to use for the call</param>
        /// <param name="procedure">Generic Typed stored procedure object</param>
        /// <param name="data">The actual object containing the parameter data</param>
        /// <returns></returns>
        public static ResultsList CallStoredProc <T>(this DbContext context, StoredProc <T> procedure, T data)
        {
            IEnumerable <SqlParameter> parms = procedure.Parameters(data);
            ResultsList results = context.ReadFromStoredProc(procedure.fullname, parms, procedure.returntypes);

            procedure.ProcessOutputParms(parms, data);
            return(results ?? new ResultsList());
        }
Esempio n. 2
0
        /// <summary>
        /// Call a stored procedure, passing in the stored procedure object and a list of parameters
        /// </summary>
        /// <param name="context">Database context used for the call</param>
        /// <param name="procedure">Stored Procedure</param>
        /// <param name="parms">List of parameters</param>
        /// <returns></returns>
        public static ResultsList CallStoredProc(this DbContext context, StoredProc procedure, IEnumerable <SqlParameter> parms = null)
        {
            ResultsList results = context.ReadFromStoredProc(procedure.fullname, parms, procedure.returntypes);

            return(results ?? new ResultsList());
        }
Esempio n. 3
0
        /// <summary>
        /// Generic Typed version of calling a stored procedure
        /// </summary>
        /// <typeparam name="T">Type of object containing the parameter data</typeparam>
        /// <param name="context">Database Context to use for the call</param>
        /// <param name="procedure">Generic Typed stored procedure object</param>
        /// <param name="data">The actual object containing the parameter data</param>
        /// <returns></returns>
        public static int ExecuteStoredProcNonQueryWithReturnValue <T>(this DbContext context, StoredProc <T> procedure, T data)
        {
            IEnumerable <SqlParameter> parms = procedure.Parameters(data);
            ResultsList results = context.ReadFromStoredProc(procedure.fullname, parms, procedure.returntypes);

            procedure.ProcessOutputParms(parms, data);
            return((int)parms.Where(p => p.Direction == ParameterDirection.ReturnValue).SingleOrDefault().Value);
        }