IDataAccessAdapter.Dispose()

Posts   
 
    
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 01-May-2005 23:48:35   

Hi,

It says in the manual that 'adapter.Dispose();' is a necessary action to perform when using manual transactions.

However, if I'm programming against 'IDataAccessAdapter', I can call 'StartTransaction' etc. and thus do manual transactions but I cannot call 'Dispose' because its not part of the interface.

So I have to know the concrete class or at least the base of the concrete class at the end of the reference (which luckily I do...DataAccessAdapterBase) in order to correctly use the object which, I believe, defeats the point of programming against an interface.

What do you think about this?

Ian.

Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 01-May-2005 23:50:57   

Aha! You can completely ignore me here. One just needs to cast to nice and generic 'IDisposable'.

Marcus avatar
Marcus
User
Posts: 747
Joined: 23-Apr-2004
# Posted on: 02-May-2005 00:19:30   

Ian wrote:

Aha! You can completely ignore me here. One just needs to cast to nice and generic 'IDisposable'.

or use:


public static int Delete(string displayName)
{
    using (DataAccessAdapter adapter = new DataAccessAdapter())
    {
        return Delete(displayName, adapter);
    }
}

public static int Delete(string displayName, IDataAccessAdapter adapter)
{ 
    ...
}

as DataAccessAdapter implements IDataAccessAdapter and it can be passed around using the interface...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 02-May-2005 09:13:06   

Ian wrote:

Aha! You can completely ignore me here. One just needs to cast to nice and generic 'IDisposable'.

Or cast to the base class DataAccessAdapterBase.

Dispose is stated to be essential, because for firebird it is, for other drivers it's not that essential, but to avoid errors, it's stated to be essential. simple_smile

Frans Bouma | Lead developer LLBLGen Pro