views:

275

answers:

2

TableAdapter is a wrapper for DataAdapter. It's impossible to use TableAdapters in generic way (bacause they inherit Component class). Is it possible to get the wrapped DataAdapter out of TableAdapter?

A: 

Each table adapter contains the designer generated methods, which are not standard... rather than working with a generic base class, I'd investigate whether you could have a table adapter implement an interface because that would be easier to implement and still not lose the strong typing. I believe the table adapter is a partial class, and you can create a class:

public partial class MyTableAdapter : ISomeInterface

Which this interface can have your custom methods defined. I'm not sure about the partial thing, but I'm pretty sure they are partial classes.

Brian
+1  A: 

As Brian pointed out, a table adapter is a partial class. If you want to expose the DataAdapter you can achieve that by the following code. (assuming you have a TableAdapter class MyTableAdapter.

public partial class MyTableAdapter
{
    public DbDataAdapter Adapter
    {
        get { return this._adapter; }
    }
}

Alternatively, you could write some general purpose method (or extension method) that returns the private adapter using reflection. That way you wouldn't have to "touch" every table adapter you create.

Kim Major