示例#1
0
        public async Task <IEnumerable <CaseReportFromUnknownDataCollectorExpanded> > Get()
        {
            var anonymousCaseReports = await _caseReportsFromUnknownDataCollectors.GetAllAsync();

            // Comment from woksin - 15/02-2018
            // By fetching all risks to memory we should get reduced latency,
            // which was the case when I tested this method using the old method versus fetching the data prior to querying it.
            // In my opinion, the best way to do this is to have a cache-system for these databases (preferably in the classes that deals directly
            // with IMongoDatabase and IMongoCollection
            var healthRisks = await _healthRisks.GetAllAsync();

            // Comment from review; einari - 23rd of October 2017
            // Todo: This is a N+1 query - potentially incredibly slow
            // an optimization would be to get all healthrisks and then
            // do inmemory lookups. Also moved this away from being done inside the CaseReportExtended
            // object - as it should not be having a relationship to repositories

            return(anonymousCaseReports.Select(caseReport => {
                var healthRisk = healthRisks.FirstOrDefault(risk => risk.Id == caseReport.HealthRiskId);


                //var healthRisk2 = _healthRisks.GetById(caseReport.HealthRiskId);
                return new CaseReportFromUnknownDataCollectorExpanded(caseReport, healthRisk);
            }));
        }
示例#2
0
 public async Task <IEnumerable <HealthRisk> > Get()
 {
     return(await _healthRisks.GetAllAsync());
 }
示例#3
0
 public async Task <IActionResult> Get()
 {
     return(Ok(await _healthRisks.GetAllAsync()));
 }