title: Using C# Linq's ToDictionary from DataTable
body: <p>I have a sql query that I return into a DataTable:</p>
  
  <pre><code>SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_LENGTH 
  FROM USER_TAB_COLUMNS
  WHERE TABLE_NAME IN (SELECT DBTABLE FROM MY_APP_SETTINGS)
  </code></pre>
  
  <p>With this, I want to create a <code>Dictionary&lt;string, List&lt;ColumnInfo&gt;&gt;</code>, where the key is TABLE_NAME and ColumnInfo is a custom class with properties to match the other three fields returned in the query.  So, far I have:</p>
  
  <pre><code>IEnumerable&lt;DataRow&gt; rows = MyDataTable.Rows.Cast&lt;DataRow&gt;();
  var ExistingColumns = MyDataTable.AsEnumerable().Select(dataRow =&gt; rows
      .Select(row =&gt; new { 
          Key = row["TABLE_NAME"], 
          Value = new ColumnInfo(){ 
              ColumnName = row["COLUMN_NAME"].ToString(), 
              DataType = row["DATA_TYPE"].ToString(), 
              DataLength = int.Parse(row["DATA_LENGTH"].ToString())
          }
      }).ToDictionary(data =&gt; data.Key, data =&gt; data.Value));
  </code></pre>
  
  <p>However, this has two problems: 1) There are duplicate keys, and 2) the Value is just a single instance of the class, not a collection.</p>
  
  <p>How can I acheive this conversion using linq?</p>
  
  <p>Thanks!</p>