This is my entity collection.
Dictionary<string, List<Dictionary<string, string>>> EntityCollection = new Dictionary<string, List<Dictionary<string, string>>>();
When I receive value in EntityCollection, I want to filter it.
var filtered = from entity in EntityCollection
where entity.Key == entityId
select entity.Value;
Now I want only entity.value.
So I created a variable:
List<Dictionary<string, string>> entityDetails = new List<Dictionary<string, string>>();
How can I cast filtered to entityDetails?
I tried with filtered.ToList<Dictionary<string, string>>, but no success.
You can get directly from
Dictionaryinstead of using LINQ like yours:Or if you want to avoid exception from the first approach if dictionary does not have a key