title: Building LINQ query to get List of Dictionaries from Dictionary of string/HashSet of Dictionary of String/String?
body: <p>I need to convert one traditional logic into LINQ query (Method Syntax).</p>
  
  <p>I looked at few questions already asked on this forum. One that came very close to my scenario is this: <a href="https://stackoverflow.com/questions/33055423/dictionarystring-listdictionarystring-string-query-using-linq">Dictionary&lt;string, List&lt;Dictionary&lt;string,string&gt;&gt;&gt; query using linq</a>. But I am still having difficulty converting my following logic into equivalent LINQ (Method Syntax) query. I need help. I am still learning LINQ, so please bear with me.</p>
  
  <pre><code>Dictionary&lt;String, HashSet&lt;Dictionary&lt;String, String&gt;&gt;&gt; myData = BuildMyData();
  String givenKey = GetGivenKey();
  String givenValue = GetGivenValue();
  
  // I need LINQ (Method syntax) equivalant to following logic:
  List&lt;Dictionary&lt;String, String&gt;&gt; matched = new List&lt;Dictionary&lt;String, String&gt;&gt;();
  foreach(KeyValuePair&lt;String, HashSet&lt;Dictionary&lt;String, String&gt;&gt;&gt; kvp in myData)
      foreach (Dictionary&lt;String, String&gt; dict in kvp.Value)
          if (dict.ContainsKey(givenKey) &amp;&amp; dict[givenKey] == givenValue)
          {
              matched.Add(dict);
              break;
          }
  </code></pre>
  
  <p>How can I build <code>matched</code> using LINQ methods syntax?</p>
  
  <p>I tried following, but this gives me two errors - </p>
  
  <pre><code>matched = myData.Where(kvp =&gt; kvp.Value.Where(dict =&gt;
                  dict.ContainsKey(givenKey) &amp;&amp; dict[givenKey] == givenValue)).ToList();
  </code></pre>
  
  <p>But that gives me two errors:</p>
  
  <ul>
  <li>CS0029 Cannot implicitly convert type 'System.Collections.Generic.IEnumerable>' to 'bool'</li>
  <li>CS1662 Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type</li>
  </ul>
  
  <p>What am I doing wrong? and How do I fix it?</p>