...
This is good. The database will probably stay with Oracle, SQL Server,
IBM, MS Access, and MySQL. What exactly does the DB proxy layer do?
It only provides a "glue layer" between your "SQL-layer" and the
ADO.NET-driver.
Small "pseudo-example":
interface IDbProxy
{
IDbConnection GetConnection( string cns );
IDbCommand CreateCommand( );
...
}
class OracleProxy : IDbProxy
{
IDbConnection GetConnection( string cns )
{
return new OracleConnection( cns );
}
IDbCommand CreateCommand()
{
return new OracleCommand();
}
...
}
In your SQL-layer only the IDbProxy-interface is exposed, through some
plugin-mechanism (for the latter there are a lot of different techniques,
that I'm sure you can find in a lot of different places).
What exactly do you mean here? Can you give an example?
You could actually get away with only a single proxy if you use
reflection... ;-)
Through reflection you can dynamically load the ADO.NET-driver, using some
kind of "ini-file" to let the proxy know where to look for it, which
classnames are used for the driver, connection-strings, etc.
The key is still to *not* expose any DB-specific classes from the proxy,
only the necessary interfaces (IDbConnection, IDbCommand, etc).
I made exactly this in Java a couple of years ago, to be able to switch
freely between different DBs and make adhoc queries, and I will soon be
working on a similar one for C#/.NET...
Unfortunately I haven't started on it, so I don't have any code to show
yet... ;-)
Say in the future, some one wants to use my app but they have a database
which doesn't support standard SQL. I could keep trying to get as generic
as possible but I loose much power. I would simply define the domain of
database this app will interact with and stay there. This means standard
SQL will always be available. Does this change your thoughts on using a
higher abstraction layer?
You never know what the future holds...
I would still look at the "data layer" from both perspectives, i.e. from the
"Business Perspective" and from the "DB-perspective".
What do I need to store persistent?
That would make up a layer between the business logic and the data layer,
focusing on storing and retrieval of the explicit data, but free from other
considerations in the business logic, and free to make use of different
DB-approaches. Though it would be dependant on the rest of the business
logic, it frees the layer from the details of SQL, if you in the future want
to make use of another DB than those supporting SQL.
// Bjorn A