title: Conversion of DataTable to Dictionary<String,StringBuilder>
body: <p>DataTable has following column names:</p>
  
  <pre><code>Name, Value, Type, Info
  </code></pre>
  
  <p>Need to convert a structure Dictionary</p>
  
  <p>Where Name is the Key (string) and other values will be appended to the StringBuilder like "Value,Type,Info", however it is possible to have repetitive Name column value, then successive each appended value to the StringBuilder will use a separator like ?: to depict the next set of value.</p>
  
  <p>For eg: if the DataTable data is like:</p>
  
  <pre><code>Name, Value, Type, Info
  
  one     1     a   aa
  one     11    b   bb
  two     2     c   cc
  two     22    dd  ddd
  two     222   ee   eee
  </code></pre>
  
  <p>Now the result structure should be like:</p>
  
  <pre><code>Dictionary&lt;String,StringBuilder&gt; detail = new Dictionary&lt;String,StringBuilder&gt;
  {
  {[one],[1,a,aa?:11,b,bb},
  {[two],[2,c,cc?:22,dd,ddd?:222,ee,eee}
  }
  </code></pre>
  
  <p>It is easy to achieve the same using for loop, but I was trying to do it via Linq, so I tried something like:</p>
  
  <pre><code>datatable.AsEnumerable.Select(row =&gt;
  {
    KeyValuePair&lt;String,StringBuilder&gt; kv = new  KeyValuePair&lt;String,StringBuilder&gt;();
  
   kv.key = row[Name];
   kv.Value = row[Value]+","+row[Type]+","+row[Info]
  
   return kv;
  }).ToDictionary(y=&gt;y.Key,y=&gt;y.Value)
  </code></pre>
  
  <p>This code doesn't take care of repetitive keys and thus appending, probably I need to use SelectMany to flatten the structure, but how would it work in giving me a dictionary with requirements specified above, so that delimiters can be added to be existing key's value. Any pointer that can direct me in the correct direction.</p>