public IEnumerable <ReleaseRetentionResult> GetRecentReleases(int?limit = null) { if (limit <= 0) { // Handle bad input return(new ReleaseRetentionResult[0]); } // Get all of the data required and convert environments, projects and releases to dictionaries for faster lookup given larger data sets Dictionary <string, EnvironmentModel> environments = _environmentDataService.Query().ToDictionary(e => e.Id, e => e); Dictionary <string, ProjectModel> projects = _projectDataService.Query().ToDictionary(p => p.Id, p => p); Dictionary <string, ReleaseModel> releases = _releaseDataService.Query().ToDictionary(r => r.Id, r => r); return(GetRecentReleasesForDeployments(_deploymentDataService.Query(), projects, environments, releases, limit)); }