Suppose I am developing a class that can process any database technology to create a connection, execute a command, and receive data, etc.
If I need to create a common database processing class for existing RDBMS (for example, SQL Server, Oracle, FireBird, etc.) that .net abstract-class / Interface should use {DbConnection, DbCommand, DbParameter, ...} or {IDbConnection, IDbCommand, IDbParameter, ...}?
Should I use code like
public bool CreateConnection(DatabaseTypeEnum type)
{
DbConnection conn ;
if(type==DatabaseTye.Oracle)
{
}
}
public DbDataReader GetData()
{
DbCommand comm;
}
or,
public bool CreateConnection(DatabaseTypeEnum type)
{
IDbConnection conn ;
if(type==DatabaseTye.Oracle)
{
}
}
public IDbDataReader GetData()
{
IDbCommand comm;
}
And why?
source
share