I'm using LinqToSql
in one of my projects and I want a bunch of tables to do something when they are loaded.
Each table implements a partial class an inherits a base class that does some business logic.
My code looks something like this:
public partial class Table1 : MyBaseClass {}
public partial class Table2 : MyBaseClass {}
..
public partial class Table150 : MyBaseClass {}
public abstract class MyBaseClass
{
public void OnLoaded()
{
// do something
}
// more code
}
The partial void OnLoaded
method suits me, but I don't want to re-implement the method on every table.
Since I didn't find a way to do things it will make me implement my tables and look something like this:
public partial class Table1 : MyBaseClass
{
// This code is "redundant"
public partial void OnLoaded() // partial method
{
base.OnLoaded(); // non partial base method
}
}
I can't use a code generator like T4Templates
or something since I don't know the exact table names that I need plus some tables will need to do some specific overriding's in their partial class.
I'd like somehow to implement the partial method using the base implementation.
Is there any nice approach to achieve something like this? Or even something similar?