title: C# DataTable to Dictionary with multiple values
body: <p>I have a DataTable that returns me data as follows:</p>
  
  <pre><code>APP | VERSION
  ____|________  
  app1| 1.0
  app1| 2.0
  app1| 3.0
  app2| 1.0
  app3|  
  </code></pre>
  
  <p>As you see, "app1" has multiple versions, and some apps don't have any versions. I need to store this Datatable result in some sort of List for later usage in my code, so I came up with Dictionary, but can't get It to work. Here is what I tried:</p>
  
  <pre><code>    public static Dictionary&lt;string, List&lt;string&gt;&gt; AppVer()
          {
           string SQL = "SELECT column1, column2 FROM myTable a LEFT JOIN 
           myTable2 v ON v.ID_FK=a.ID_PK";
           Dictionary&lt;string, List&lt;string&gt;&gt; versions = new Dictionary&lt;string, 
           List&lt;string&gt;&gt;();
  
           DataTable dt = new DataTable();
  
              try
              {
                  using (var conn = new OracleConnection(conn_string))
                  {
                      conn.Open();
  
                      using (OracleCommand cmd = new OracleCommand(SQL, conn))
                      {
                          using (OracleDataAdapter dad = new OracleDataAdapter(cmd))
                          {
                              dad.Fill(dt);
                          }
                          versions = dt.AsEnumerable().ToDictionary&lt;DataRow, string, List&lt;string&gt;&gt;(row =&gt; row[0].ToString(), new List&lt;string&gt;(row=&gt; row[1].ToString()));
                      }
                  }
              }
              catch (Exception ex)
              {
                  MessageBox.Show(ex.Message);
              }
               return versions;
          }
  </code></pre>
  
  <p>However, I get error </p>
  
  <blockquote>
    <p>"Cannot convert lambda expression to type 'string' because it is not a
    delegate type".</p>
  </blockquote>
  
  <p>How could I store my DataTable to dictionary ?</p>
  
  <p>EDIT:</p>
  
  <pre><code> Dictionary&lt;string, List&lt;Version&gt;&gt; all_versions =  AppVer();
  
              StringBuilder sb = new StringBuilder();
  
              foreach (var item in all_versions)
              {
                  sb.AppendFormat("{0} - {1}{2}", item.Key, item.Value, Environment.NewLine);
              }
  
              string result = sb.ToString().TrimEnd();
              MessageBox.Show(result);
  </code></pre>