How to intersect results after GroupBy
<p>To illustrate my problem I have created this simple snippet. I have a class <code>Item</code> </p>

<pre><code>public class Item
{
    public int GroupID { get; set; }
    public int StrategyID { get; set; }

    public List&lt;Item&gt; SeedData()
    {
        return new List&lt;Item&gt;
        {
            new Item {GroupID = 1, StrategyID = 1 },
            new Item {GroupID = 2, StrategyID = 1 },
            new Item {GroupID = 3, StrategyID = 2 },
            new Item {GroupID = 4, StrategyID = 2 },
            new Item {GroupID = 5, StrategyID = 3 },
            new Item {GroupID = 1, StrategyID = 3 },
        };
    }
}
</code></pre>

<p>And what I want to check is that this <code>SeedData</code> method is not returning any duplicated <code>GroupID/StrategyID</code> pairs.</p>

<p>So in my <code>Main</code> method I have this:</p>

<pre><code>Item item = new Item();
var data = item.SeedData();

var groupByStrategyIdData = data.GroupBy(g =&gt; g.StrategyID).Select(v =&gt; v.Select(gr =&gt; gr.GroupID)).ToList();

for (var i = 0; i &lt; groupByStrategyIdData.Count; i++)
{
    for (var j = i + 1; j &lt; groupByStrategyIdData.Count; j++)
    {
             Console.WriteLine(groupByStrategyIdData[i].Intersect(groupByStrategyIdData[j]).Any());
    }
}
</code></pre>

<p>which is working fine but one of the problems is that I have lost the <code>StrategyID</code> so in my real-case scenario I won't be able to say for which <code>StrategyID/GroupID</code> pair I have duplication so I was wondering is it possible to cut-off the <code>LINQ</code> to here:</p>

<pre><code>var groupByStrategyIdData = data.GroupBy(g =&gt; g.StrategyID)
</code></pre>

<p>and somehow perform the check on this result?</p>