title: LINQ Lambda, Group by with list
body: <p>I'm having some trouble with finding the right syntax to accomplish the following:</p>
  
  <p>Is it possible with LINQ (Lambda Expression) to .GroupBy data and instead of using the usual .Sum() or .Count() I want the resulting data to be a List of Int.</p>
  
  <p>I defined my own class named: Filter_IDs. Its constructor needs two parameters:</p>
  
  <pre><code>public int? type; // Represents the object_type column from my database
  public List&lt;int?&gt; objects; // Represents the object_id column from my database
  </code></pre>
  
  <p>I want to load data from my database into this object. The following LINQ query should result in a List of Filter_IDs:</p>
  
  <p>The following LINQ query should result in a List of Filter_IDs:</p>
  
  <pre><code>List&lt;Filter_IDs&gt; filterids = ef.filterLine
          .GroupBy(fl =&gt; fl.objectType)
      .Select(fl =&gt; new Filter_IDs { type = fl.Key, objects = fl.Select(x =&gt; x.object_id).ToList() })
      .ToList();
  </code></pre>
  
  <p>Using this query gives no building error but gives an 'NotSupportedException' on RunTime.</p>
  
  <p>The database looks like this to give you a better understanding of the data:</p>
  
  <p><a href="http://d.pr/i/mnhq+" rel="noreferrer">http://d.pr/i/mnhq+</a> (droplr image)</p>
  
  <p>Thanks in advance,
  Gerben</p>