Strongly Typed Dataset functionality
I've written a class that wraps up any database queries with the following added functionality:
Automatic retry on timeout
Automatic reopen on connection closed
Thread Safety
Limited Auto Transfer of data between 2 tables/2 connections/disparate types (including submitting X number of insert statements at once as a batch.) used this one to move 7000 insert statements per trip to the db and moved a 600k+ table close to the speed SSIS achieved. I didn't even make use of threading where SSIS I believe used around 3 threads.
Mapping of some MSSQL, excel, and teradata functions.
Mapping of a few provider's preferred date format.
So I'd like to venture into strongly typed datasets but I Can't seem to find a way to hook generically into any Auto-generated table adapters and use my code, or write new code for these types of functionality that would work with any table adapter. Table adapters inherit from System.ComponentModel.Component so that doesn't expose anything useful for a generic wrapper to make use of =(.
I know table adapters are written as a partial class, but this only allows for snippet based code generation easily. I'd rather have a class-based or generic wrapper based solution.
Any ideas?
Re: Strongly Typed Dataset functionality
Each TableAdapter is written from scratch as required. It is a wrapper for a DbDataAdapter, the actual type of which depends on the database being accessed. As with most auto-generated code, all the classes generated by the Data Source wizard are partial, which allows you to define your own partial class to add functionality without interfering with the auto-generated code or losing your own code when it's regenerated. Assuming that you have a SomeTableAdapter class, you can extend it like so:
vb.net Code:
Namespace SomeDataSetTableAdapters
Partial Public Class SomeTableAdapter
End Class
End Namespace
Inside that class you have access to all the private members of the class, including the DataAdapter and the Connection.
Re: Strongly Typed Dataset functionality
Quote:
Originally Posted by
MaslowB
I know table adapters are written as a partial class, but this only allows for snippet based code generation easily. I'd rather have a class-based or generic wrapper based solution.
I'd like something write once based and plug in or call to wrap. like a class that accepts a dataadapter. I thought about exposing the command collection like most the modify dataAdapter posts on the net say to do, but since my class is a wrapper to the command and connection peices that wouldn't help really. Can you think of something to expose or hook into on a partial class that would be just a small snippet of code to let me plug and play this type of functionality with a class that is reuseable?
I'm thinking that implementing an interface in the partial snippet so that the generic class could constrain to system.componentModel that dataadapters inherit from and also constrain to the interface that the partial class could expose hooks to.