Parallel.Foreach issue
<p>I have a <code>Parallel.Foreach</code> loop that is giving me grief, and wanted to see if one of you guys could shed some light on this. Little to be found googling this unfortunately.</p>

<p>Here is the knot:</p>

<p>My foreach loop :</p>

<pre><code>string [] Ids = {........}; //a string array of ID's
using(IUnitOfWork uw = GetUnitOfWork())
     {
            Parallel.ForEach(Ids, currentRecord =&gt;
            {
                var x = (from h in uw.GetRepository&lt;EFEntity1&gt;().AsQueryable()
                         join k in uw.GetRepository&lt;EFEntity2&gt;().AsQueryable()
                         on h.ID equals k.ID
                         join l in uw.GetRepository&lt;EFEntity3&gt;().AsQueryable() on 
                          h.FundAccount equals l.FundAccount
                         where h.ID == currentRecord
                         select new { h.x, h.y, h.z});
                foreach (var v in x)
                {
                    if (v.SomeMember == "foo")
                    {

                    }
                    Console.WriteLine("Output : {0} {1} {2} {3} {4} ", v.x, 
                                      v.y, v.z);
                }
            });
        }
</code></pre>

<p>The LINQ statement is where I get an <code>ArgumentExcpetion</code> thrown saying:</p>

<blockquote>
  <p><em>An item with the same key has already been added</em></p>
</blockquote>

<p>Any clues to what might be wrong with my implemntation of the foreach loop in this scenario?</p>

<p>Appreciate the support.</p>

<p>Thanks</p>
