public T GetDataset <T>(string name) where T : class { int datasetCount = Datasets.Count(x => x.Name == name); if (datasetCount == 0) { throw new Exception($"The dataset '{name}' was not found."); } if (datasetCount > 1) { throw new Exception($"More than one datasets with name '{name}' were found. Only one should exist."); } return(Datasets.First(x => x.Name == name).Properties.TypeProperties as T); }