コード例 #1
0
        /// <summary>
        /// Retrieves list of CompanyBranch objects from SqlCommand, after database query
        /// number of rows retrieved and returned depends upon the rows field value
        /// </summary>
        /// <param name="cmd">The command object to use for query</param>
        /// <param name="rows">Number of rows to process</param>
        /// <returns>A list of CompanyBranch objects</returns>
        private CompanyBranchList GetList(SqlCommand cmd, long rows)
        {
            // Select multiple records
            SqlDataReader reader;
            long          result = SelectRecords(cmd, out reader);

            //CompanyBranch list
            CompanyBranchList list = new CompanyBranchList();

            using ( reader )
            {
                // Read rows until end of result or number of rows specified is reached
                while (reader.Read() && rows-- != 0)
                {
                    CompanyBranch companyBranchObject = new CompanyBranch();
                    FillObject(companyBranchObject, reader);

                    list.Add(companyBranchObject);
                }

                // Close the reader in order to receive output parameters
                // Output parameters are not available until reader is closed.
                reader.Close();
            }

            return(list);
        }
コード例 #2
0
        /// <summary>
        /// Retrieves all CompanyBranch objects by PageRequest
        /// </summary>
        /// <returns>A list of CompanyBranch objects</returns>
        public CompanyBranchList GetPaged(PagedRequest request)
        {
            using (SqlCommand cmd = GetSPCommand(GETPAGEDCOMPANYBRANCH))
            {
                AddParameter(cmd, pInt32Out("TotalRows"));
                AddParameter(cmd, pInt32("PageIndex", request.PageIndex));
                AddParameter(cmd, pInt32("RowPerPage", request.RowPerPage));
                AddParameter(cmd, pNVarChar("WhereClause", 4000, request.WhereClause));
                AddParameter(cmd, pNVarChar("SortColumn", 128, request.SortColumn));
                AddParameter(cmd, pNVarChar("SortOrder", 4, request.SortOrder));

                CompanyBranchList _CompanyBranchList = GetList(cmd, ALL_AVAILABLE_RECORDS);
                request.TotalRows = Convert.ToInt32(GetOutParameter(cmd, "TotalRows"));
                return(_CompanyBranchList);
            }
        }
コード例 #3
0
        /// <summary>
        /// Retrieve list of CompanyBranch.
        /// </summary>
        /// <param name="fillChild"></param>
        /// <returns>List of CompanyBranch</returns>
        public CompanyBranchList GetAll(bool fillChild)
        {
            CompanyBranchList companyBranchList = new CompanyBranchList();

            using (CompanyBranchDataAccess data = new CompanyBranchDataAccess(ClientContext))
            {
                companyBranchList = data.GetAll();
            }
            if (fillChild)
            {
                foreach (CompanyBranch companyBranchObject in companyBranchList)
                {
                    FillCompanyBranchWithChilds(companyBranchObject, fillChild);
                }
            }
            return(companyBranchList);
        }