This project is read-only.
Usage of Data Table Proxy

The Short, Short version
1) Declare yourself a DataTableProxy<T>.
2) Set the DataSource property of your DataTableProxy<T> to your IEnumerable<T>.
3) Call .ColumnDefs.Add() to pass in each column definition. A column definition is a string (for the title) as key, with a delegate Func<T, Object> as the value.
4) Call .FillTable.
5) The Table property of your DataTableProxy object will have your filled, completed DataTable.

Example -

var dtp = new DataTableProxy<Customer>();
dtp.DataSource = ActiveCustomers; // a preloaded collection.
dtp.ColumnDefs.Add("ID", c => c.CustomerID);
dtp.ColumnDefs.Add("Name", c=> c.CustomerName);
dtp.ColumnDefs.Add("Most Recent Order Date", c => c.orders.OrderByDesc(o => o.OrderDate).FirstOrDefault.OrderDate);
dtp.ColumnDefs.Add("Order Count", c => c.Orders.Count());
this.DataGridView1.DataSource = dtp.Table;

Last edited Nov 19, 2009 at 6:16 PM by TDietrich513, version 1


No comments yet.