Exemplo n.º 1
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)
        {
            var results = context.ReadFromStoredProc(procedure.FullName, parms, procedure.Returntypes);

            return(results ?? new ResultsList());
        }
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);
            var parms = procedure.Parameters(data);

            if (parms != null)
            {
                //ResultsList results = context.ReadFromStoredProc(procedure.FullName, parms, procedure.Returntypes);
                var results = context.ReadFromStoredProc(procedure.FullName, parms, procedure.Returntypes);
                procedure.ProcessOutputParms(parms, data);
                return(results ?? new ResultsList());
            }
            return(new ResultsList());
        }