title: ForEach to Lambda with two list in C#
body: <pre><code>foreach (var item in lstObj)
          {
              item.links = new List&lt;ObjTest&gt;();
              foreach (var rel in item.relations)
              {
                  foreach (var item2 in lstObj)
                  {
                      if (rel.Object_ID2 == item2.ID)
                      {
                          item.links.Add(item2);
                      }
                  }
              }
          }
  </code></pre>
  
  <p>I'd like to change this into lambda expression but i don't get it !</p>
  
  <p>Here is the objects classes :</p>
  
  <pre><code>ObjTest
      public int ID
      public string content;
      public List&lt;ObjRelation&gt; relations; //relations with other ObjTest object
      public List&lt;ObjTest&gt; links; //objTest objects of relations
  
  ObjRelation
      public int ID;
      public int object_ID1;       
      public int object_ID2;
  </code></pre>
  
  <p>So an ObjTest contains two list, [relation] and [links]</p>
  
  <p>In [relation] we have a description of relations that an ObjTest has. </p>
  
  <p>In [Links] we have the object(s) linked to the ObjTest, in relation with the object's ids we have in the relations list.</p>
  
  <p>My goal was to put in [links] objects presents in lstObj, but filtered by the ids (object_ID2) presents in [relations] list of each ObjTest in lstObj.</p>
  
  <p>I did it, but i'd like to translate this forEach into lambda expression. I Tried some things but it won't work :/</p>