Generic TableAdapter updates
Hello,
I understand why it is difficult to use TableAdapters generically (ie they
really only exist in the mind of the Code Generator!)......
I have an ancestor UserControl from which I inherit many concrete
UserControls. Each of those concrete controls has a number of TableAdapter
and DataSet combinations. At the moment, my save logic is along the lines
of:
ta1.Update(ds1.sometable)
ta2.Update(ds1.someothertable)
I would really like to encapsulate the update logic in the ancestor class,
so that my concrete classes could say something along the lines of:
DoSave(ta1, ds1.sometable)
DoSave(ta2, ds1.someothertable)
Then, the ancestor can include some Try Catch logic and so on to make it all
more robust - but without needing to repeat the same boilerplate code over
and over in the concrete classes. I have read various things about changing
the base class of the TableAdapter and about using partial classes. How
have others done this?
Better still would be if my concrete class could just say:
DoSave()
and leave it up to the ancestor to find all the TableAdapters and update
them all. I don't think this is really viable, as there is nothing to tie
the TableAdapters to specific DataTables.
Clues welcome, thanks.
Nick
Date:Sun, 12 Aug 2007 21:41:22 +0100
Author:
|