C# – subsonic – collection load versus query

csubsonic

I am setting the data source of a datagridview to a subsonic collection

        TcolorCollection tc = new TcolorCollection().Load();
        dataGridView1.DataSource = tc;

and I've noticed that the previous code is much (way to much) slower then the following

        SubSonic.Query q3 = new SubSonic.Query("tcolor");
        q3.QueryType = SubSonic.QueryType.Select;
        IDataReader reader = q3.ExecuteReader();
        DataTable dt = new DataTable();
        dt.Load(reader);
        dataGridView1.DataSource = dt;

I would like to use the collection class and it's connectivity, but I need a way for the .Load() to be faster.

fyi the table I am using has 8000+ records. Not small, but not huge either.

Best Answer

Couple of thoughts...

If you have to use a DataSet/DataTable you could just do this:

grid.DataSource=new Select().From("tcolor").ExecuteDataSet();

Both of the things you show above use the same core bits - not sure why one is slower than the other.