private static void GenerateQuery(QueryDefinition queryDefinition, QueryList inputList, QuerySet querySet) { if (queryDefinition.Grouping == QueryGrouping.Area) { foreach (var area in inputList.Areas) { var areaQueries = querySet.EnsureArea(area.Name); // Filter by 'queries' if present. if (area.Queries.Any(q => string.Equals(q, queryDefinition.Id))) { areaQueries.Queries.Add(GenerateAreaQuery(queryDefinition, area)); } } } else { throw new NotSupportedException("Only area-grouped queries are supported at this time."); } }