Esempio n. 1
0
        /// <summary>
        /// Executes DB SELECT statement (mostly based on where clause) and returns only one row as object of supplied class.
        /// </summary>
        /// <returns>
        /// Object of generic class result.
        /// </returns>
        public static T GetSpecific(T obj, string strProcName)
        {
            T result;

            try
            {
                List <T>       list      = new List <T>();
                SqlParameter[] parameter = Util.GetParameter(obj);
                object         obj2      = sdh.ExecuteDataSet(Util.CS(), strProcName, CommandType.StoredProcedure, parameter);
                list = ListProvider <T> .FindAll((DataSet)obj2);

                result = ((list.Count > 0) ? list[0] : new T());
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Executes DB SELECT statement (Capabilities to return all or paginated format based on stored procedure design)
        /// and returns query result in generic list format of supplied class.
        /// </summary>
        //
        /// <returns>
        /// List of generic class result.
        /// </returns>
        public static List <T> GetAllOrByRange(T obj, string strProcName)
        {
            List <T> result;

            try
            {
                List <T>       list      = new List <T>();
                SqlParameter[] parameter = Util.GetParameter(obj);
                object         obj2      = sdh.ExecuteDataSet(Util.CS(), strProcName, CommandType.StoredProcedure, parameter);
                list = ListProvider <T> .FindAll((DataSet)obj2);

                result = list;
            }
            catch (Exception ex)
            {
                throw ex;
                //return new List<T>();
            }
            return(result);
        }