View Single Post
  #2 (permalink)  
Old March 30th, 2009, 09:30 PM
varallov varallov is offline
Wrox Author
 
Join Date: Jan 2009
Posts: 73
Thanks: 0
Thanked 7 Times in 7 Posts
Default

Great question. What you can do is modify the ENTBaseData class so the DataContext is a generic parameter.

publicabstractclassENTBaseData<T, DC>
where T : IENTBaseEntity
where DC: DataContext, new()
{
publicabstractList<T> Select();
publicabstract T Select(int id);
publicabstractvoid Delete(DC db, int id);
publicvoid Delete(string connectionString, int id)
{
using (DC db = new DC(connectionString))
{
Delete(db, id);
}
}

Replace any instance of the HRPaidTimeOffDataContext in the base class with DC. Then when you define the inheriting data classes you simply tell the compiler which DataContext to use.

publicclassMyNewClassData : ENTBaseData<ENTEmail, HRPaidTimeOffDataContext>
{
...
}

Hope this helps,
Vince