开发者

How to derive the DataSet class to add my own DataTable objects to its Tables collection?

开发者 https://www.devze.com 2023-01-18 11:53 出处:网络
I create开发者_JAVA百科d my own class derived from DataTable and added some properties. This class is called mpdvDataTable and works just like expected.

I create开发者_JAVA百科d my own class derived from DataTable and added some properties. This class is called mpdvDataTable and works just like expected.

Now I would like to create my own DataSet class (mpdvDataSet), containing objects of type mpdvDataTable within its Tables collection.

How exactly would I do this? Any help appreciated.

Regards, Simone


A simpler approach would be to derive from DataSet and add properties (or shadows existing) to expose your data-table type. For example, you can have your own mpdvTablesCollection class shadowing .Tables property - the implementation would offer methods to manipulate mpdvTable type and will use underlying Tables collection of the base dataset. You can add typed indexer properties within your dataset class. The most important thing would be to handle CollectionChanging event of Tables collection to validate if the table being manipulated is of specified type (mvdpTable).


You need to implement also class SqlDataAdapter(), which will Fill your derived mpdvDataSet with mpdvDataTables

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号