Answer solved in edit below
I had this piece of code
Dictionary<Merchant, int> remaingCards = CardService.GetRemainingCardsNumber(int.MaxValue, 0).Result;
GetRemainingCardsNumber returns Merchants object with Id and Name property , and the matching card numbers as Int .
Now , let say I want to filter the dictionary based on the Name property inside the Merchant object . I did it like this :
cardmodel.MerchantRemainingCards = from Dictionary<Merchant, int> filterRemaining in cardserv.GetRemainingCardsNumber(int.MaxValue, 0).Result
where filterRemaining.Keys.FirstOrDefault().Name.Contains(merchantNameFilter)
select filterRemaining;
But obviously its not working because I’m not familiar with dictionary type .
— solved it here —
cardmodel.MerchantRemainingCards = cardserv.GetRemainingCardsNumber(int.MaxValue, 0).Result
.Where(e => e.Key.Name.ToLower().Contains(merchantNameFilter.ToLower()))
.ToDictionary(e => e.Key, e => e.Value);
Just cast it back to dictionary .
If, as you suggest, your first bit of code does return a
Dictionarythen you should be able to do this: