private ProjectPackageDto GetProjectPackageDto(int hubId, Package r, bool hasProjects)
        {
            Person person = r.ContactEmail != null ? _persons.FindPersonWithEmail(r.ContactEmail) : null;
            PersonDto personDto = null;
            List<FundraisingNeedDto> fundraisingNeed = r.UsePackageValue.GetValueOrDefault() ?
                _packages.GetPackageFundraisingNeedsByPackage(r.Id) :
                _packages.GetPackageFundraisingNeedsByProjects(r.Id);

            if (person != null)
            {
                personDto = new PersonDto()
                {
                    PersonEmail = person.Email,
                    PersonName = person.PersonName,
                    PersonPhone = person.PhoneNumber,
                    PersonPhoneToday = person.PhoneNumberToday
                };
            }
            return new ProjectPackageDto()
            {
                HubId = hubId,
                PackageId = r.Id,
                Priority = r.Priority,
                PackageName = r.Name,
                PackageDescription = r.Description,
                PackageFundraisingNeed = fundraisingNeed,
                UsePackageValue = r.UsePackageValue,
                PackageContact = personDto,
                HasProjects = hasProjects
            };
        }
        private void Prefetch()
        {
            using (CssDiscoveryEntities db = new CssDiscoveryEntities())
            {
                _projectPackages = db.ProjectPackageRelationship
                    .Include("Package")
                    .ToList();

                _packagesWithoutProjects = (
                    from package in db.Package
                    join rel in db.ProjectPackageRelationship
                    on package.Id equals rel.PackageID into j
                    from outerRel in j.DefaultIfEmpty()
                    where outerRel == null
                    select package
                ).Where(p => !p.DefaultPackage).ToList();

                _packageFundraisingNeedsByPackage = db.Package
                    .ToDictionary(
                        r => r.Id,
                        r => r.PackageFundraisingNeeds
                            .Select(n => new FundraisingNeedDto()
                            {
                                FiscalYear = n.FiscalYear,
                                DollarAmount = n.DollarAmount
                            }).ToList());

                _defaultPackage = db.Package.Where(r => r.DefaultPackage).FirstOrDefault();
            }

            _packageFundraisingNeedsByProject = new Dictionary<int, List<FundraisingNeedDto>>();
            using (CIHEntities db = new CIHEntities())
            {
                foreach (var packageGroup in _projectPackages.GroupBy(r => r.PackageID))
                {
                    _packageFundraisingNeedsByProject[packageGroup.First().PackageID] = packageGroup
                        .Join(db.CihProject, g => g.ProjectID, p => p.Id,
                            (r, p) => new { PackageId = r.PackageID, Project = p })
                            .Select(r => r.Project.FundraisingNeeds)
                            .SelectMany(r => r)
                            .Select(r => new FundraisingNeedDto()
                            {
                                FiscalYear = r.FiscalYear,
                                DollarAmount = r.DollarAmount
                            }).ToList();
                }
            }
        }