-1

I have Dictionary

public Dictionary<string, List<Location>> Locations { get; set; }

In location object, one key is is_update

I need to find if any of is_upate true from dictionary?

I am new in C# and did not find relevant solution for this. Any help appriciated.

Samir Bhatt
  • 3,041
  • 2
  • 25
  • 39
  • 3
    `var didIFindOne = Locations.Any(z => z.Value.Any( y => y.is_upate));` – mjwills Feb 15 '21 at 12:58
  • Does this answer your question? [Linq nested list expression](https://stackoverflow.com/questions/6144495/linq-nested-list-expression) – Self Feb 15 '21 at 13:12

2 Answers2

1

Several ways:

Locations.Values.Any(l => l.Any(x => x.is_update))

Or

Locations.Values.SelectMany().Any(x => x.is_update)
Svyatoslav Danyliv
  • 21,911
  • 3
  • 16
  • 32
0

Solution posted by @mjwills worked for me

var didIFindOne = Locations.Any(z => z.Value.Any( y => y.is_upate));
Samir Bhatt
  • 3,041
  • 2
  • 25
  • 39