title: How to convert this foreach loop into Linq code?
body: <p>I am new one with Linq and I would like to modify my old c# code to use Linq.
  The idea of this code to select all tables where it's not set and reference’s field PrimaryTable equal "myTable"</p>
  
  <pre>
  <code>
  foreach (Table table in dbServer.Tables)
              {
                  if (!table.IsSet)
                  {
                      foreach (Reference refer in table.References)
                      {
                          if (refer.PrimaryTable == "myTable")
                          {
                              tables.Add(table);
                          }
                      }
                  }
              }
  </code>
  </pre>
  
  <p>After digging in internet I have got this code</p>
  
  <pre>
  <code>
  var q = from table in dbServer.Tables
                      let refers = from refer in table.References
                                   where refer.PrimaryTable == "myTable"
                                   select refer.ForeignTable
                      where refers.Contains(table.Name)
                      select table;
  </code>
  </pre>
  
  <p>But it does not work at all and I need your help to make it works.</p>
  
  <p>Thanks in advance.</p>