private void FoundMun(IEnumerable <string> str) { var region = _repository.GetRegions(); IEnumerable <Municipality> municipality = ServiceConverter.ConvertStringToMun(str); Parallel.ForEach(region, _parallelOptions, (reg) => { foreach (var insp in reg.Inspections) { insp.Municipalities = _repository.GetMunicipalities(insp); Parallel.ForEach(insp.Municipalities, _parallelOptions, (mun) => { if (municipality.FirstOrDefault(x => x.Id == mun.Id) != null) { mun.Ifns = _repository.GetEntityIfns(mun, insp); lock (_lock) { CollectionIfns.Add(mun.Ifns); } } }); } }); }
private void FoundIfns(IEnumerable <string> str) { IEnumerable <Inspection> inspections = ServiceConverter.ConvertStringToIfns(str); Parallel.ForEach(inspections, _parallelOptions, (insp) => { insp.Municipalities = _repository.GetMunicipalities(insp); Parallel.ForEach(insp.Municipalities, _parallelOptions, (mun) => { mun.Ifns = _repository.GetEntityIfns(mun, insp); lock (_lock) { CollectionIfns.Add(mun.Ifns); } }); }); }