Beispiel #1
0
        //method implemented for readability
        //similar to user.Query()
        //query db for rows matching object using a stored proc
        public static T[] QueryWithStoredProc(string storedProc, params object[] storedProcParameters)
        {
            List <T> all = new List <T>();

            DataTable dt = DbEntityDbHandler.ExecuteStoredProc(storedProc, storedProcParameters);

            foreach (DataRow dr in dt.Rows)
            {
                T obj = new T();
                CopyDataRowValuesToObjectProperties(dr, obj);
                all.Add(obj);
            }

            return(all.ToArray());
        }
Beispiel #2
0
        //query for results from DB
        //auto populate the stored proc parameters based on the obj properties
        public virtual T[] QueryWithStoredProcAutoParams(string storedProc)
        {
            List <T> all = new List <T>();

            object[] storedProcParameters = GetStoredProcParameters(storedProc);

            DataTable dt = DbEntityDbHandler.ExecuteStoredProc(storedProc, storedProcParameters);

            foreach (DataRow dr in dt.Rows)
            {
                T obj = new T();
                CopyDataRowValuesToObjectProperties(dr, obj);
                all.Add(obj);
            }

            this.StatusCode = DbGlobals.SUCCESS_STATUS_CODE;
            this.StatusDesc = DbGlobals.SUCCESS_STATUS_TEXT;
            return(all.ToArray());
        }