title: Conversion of C# Code to LINQ C# but list adding same items
body: <p>programmers, I am trying to filter the list. I did with foreach loops and it's working fine but when I converted it to LINQ it's not working properly because the filtered list is adding the same items while I need different items picked from another list according to my condition.
  I did the following code with loops and it's working fine and showing me the result.</p>
  <pre><code>  foreach (var item in lists)
          {
              if (item.Items.Count &gt; 0)
              {
                  foreach (var newitem in item.Items)
                  {
                      foreach (var assulkeylist in list)
                      {
                          if (newitem.Href.Contains(assulkeylist.ApplicationKey))
                          {
                              if (!filteredlist.Contains(newitem))
                              {
                                  filteredlist.Add(newitem);
                              }
                             
                          }
                      }
                     
                  }
              }
              
          }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/rxGeB.png" rel="nofollow noreferrer">This is the result from using forloops</a></p>
  <p>And here what I did with <strong>LINQ C#</strong>. but it's showing me <strong>12 items</strong> and all items have same name:</p>
  <p>What code I did with LINQ given below don't know what's the problem where I am facing.</p>
  <pre><code>List&lt;ListItem&gt; filteredlist = new List&lt;ListItem&gt;();
              filteredlist = (from ListItem item in lists
                                             where item.Items.Count &gt; 0
                                             from newitem in item.Items
                                             from assulkeylist in list
                                             where newitem.Href.Contains(assulkeylist.ApplicationKey)
                                             where !filteredlist.Contains(newitem)
                                             select newitem).ToList();
  </code></pre>
  <p><a href="https://i.stack.imgur.com/sYkno.png" rel="nofollow noreferrer">Result from LINQ</a></p>