Search code examples
subsonicsubsonic3

SubSonic 3. Get results as DataTable


How can I get .All() method's result as a DataTable?

Currently it returns IQueryable, which can't be used as datasource for the WinForms DataGridView control.

dataGridView1.DataSource = Product.All(); // not working

Solution

  • You can bind a List to a DataGridView control so just use the ToList() method on the IQueryable e.g.

    MyDataGridView.DataSource = MyObject.All().ToList();