title: How to work on a "subset" of a DataTable filtered via LINQ?
body: <p>Let's say I have a table with a Color column. Color can have various values. I have a C# method that can handle items of a given column at a time. Thus, I would like to :</p>
  
  <pre><code>foreach(colorname in mytable.getDistinctColornames)
     monocolorMethod(mytable.getSubTableOnlyContainingRowsWithColor(colorname))
  </code></pre>
  
  <p>How would I do that elegantly ... ?</p>
  
  <p>At all prices, I would avoid copying the data back &amp; forth. I would like kind of a view on the datatable. A view that would only "show" the rows of a given columns, and a "writable" view (i.e. when I write to the filtered subset, the original table is written to)</p>
  
  <p><strong>EDIT :</strong></p>
  
  <p>Let's say I have a 'Car' Table, and I would like to replace 'Sedan' by 'Truck' in column 'Type' for all cars with 'Color=Red'.</p>
  
  <p>How would I do given the following code ?</p>
  
  <pre><code>DataTable cars (...); // the data
  
  DataView dv = cars.DefaultView;
  dv.RowFilter = "Color='Red'";
  </code></pre>
  
  <p>&lt; Here I would like to loop on the DataView>. The following code does not work :</p>
  
  <pre><code>foreach (row in dv.AsEnumerable)
  {
    if(row["Type"] == "Sedan")
      row["Type"] = "Truck";
  }
  </code></pre>
  
  <p>EDIT 2 :</p>
  
  <p>Found this <a href="http://msdn.microsoft.com/fr-fr/library/system.data.dataview.allowedit.aspx" rel="nofollow">http://msdn.microsoft.com/fr-fr/library/system.data.dataview.allowedit.aspx</a> which suggests</p>
  
  <pre><code>view.AllowEdit = true;
  view[0].BeginEdit();
  view[0]["FirstName"] = "Mary";
  view[0]["LastName"] = "Jones";
  view[0].EndEdit();
  </code></pre>