Exemplo 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 void ExecuteStoredProcNonQuery <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);
        }
Exemplo n.º 2
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());
        }
Exemplo 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);
        }