public List <Detector> GetAllDetectorsOfDetectionType(int detectionTypeID) { if (Detectors != null) { foreach (var d in Detectors) { if (d.DetectionTypeIDs == null) { d.DetectionTypeIDs = new List <int>(); foreach (var dt in d.DetectionTypes) { d.DetectionTypeIDs.Add(dt.DetectionTypeID); } } } return(Detectors .Where(d => d.DetectionTypeIDs.Contains(detectionTypeID)) .ToList()); } return(new List <Detector>()); }