public async Task <ReportModel> GetReport(ReportCommand reportCommand) { IQueryable <Person> recordsFiltered = _dbContext.Persons.Include(x => x.Infos) .Where(x => x.Infos.Any(info => info.InfoTypeId == (int)PeopleInfoType.Location && info.Value.Equals(reportCommand.Location))); var contactCount = await recordsFiltered.CountAsync(); var phoneNumberCount = await recordsFiltered.SumAsync(x => x.Infos.Count(info => info.InfoTypeId == (int)PeopleInfoType.Phone)); var model = new ReportModel { ContactCount = contactCount, PhoneNumberCount = phoneNumberCount, Location = reportCommand.Location }; _reportSender.ReportCompleted(model); return(model); }