private void PrefetchFundraisingNeeds() { using (CIHEntities db = new CIHEntities()) { _fundraisingNeeds = db.FundraisingNeed.ToList(); } }
private void PrefetchPersonData() { using (CIHEntities _db = new CIHEntities()) { _personData = _db.Person.ToDictionary(p => p.Id); } }
/// <summary> /// Retrieves all Hub projects with the Fundraising Flag set to true. /// </summary> /// <returns>DataTable Search Result Object</returns> public DataTableResult<FundraisingMenuResult> GetAllFundraisingMenuProjects() { DataTableResult<FundraisingMenuResult> result = new DataTableResult<FundraisingMenuResult>(); using (CIHEntities _cihContext = new CIHEntities()) { // Get data. result.data = _cihContext.CihProject.ToList() .Where(p => p.FundraisingFlag != null && p.FundraisingFlag == true) .Select(p => GetResult(p)) .ToList(); return result; } }
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(); } } }