views:

48

answers:

1

I want to have a baseclass that will assign a DataGridView's datasource property.

I am using the ActiveRecord approach so all my code generated classes are of IActiveRecord.

IRepository needs my class to instantiate it.

I cannot seem to get this to work

What I want to do is something like this..

IActiveRecord GridObject;

public void SetupGrid()
{
db = new MyDB();
repo = new Repo<GridObject>(db);
DataGridView.DataSource = repo.GetAll();
}

This does not compile.

Any tips?

A: 

This seems to compile:

        public void SetupGrid<T>() where T : class, new()
        {
            var db = new MyApp.MyDB();
            IRepository<T> repo = new SubSonicRepository<T>(db);
            dgvGrid.DataSource = repo.GetAll();

        }
Jon