I have an entity that has a property called YearsAvailible, this is a comma separated list of financial years e.g. 05,09,10
I have an API that is passes a string[]
of year names and I need to search for all of the entity that have a financial year that is in the passed array.
The best I can come up with is this:
var hash = new Hashtable();
foreach(var year in financialYears)
{
var categories = from expCat in All()
where expCat.YearsAvailable.Contains(year)
select expCat;
foreach (var category in categories)
{
if (!hash.ContainsKey(category.Id))
{
hash.Add(category.Id, category);
}
}
}
return hash.Values;
Whilst this works, it produces multiple database queries and doesn't express its intent very well. Is there a tidier way to do this?