C# / ADO.NET has:
SqlConnection / NpgsqlConnection / ...
SqlCommand / NpgsqlCommand / ...
SqlDataReader / NpgsqlDataReader / ...
...
This means that all of your DB code ends up being DB vendor specific. If you change DB vendors, you have to change all of your DB calls. And, you can't make your code DB vendor agnostic.
I don't mind creating DB vendor specific connections, but from that point forward, I want all of my DB calls to be generic, e.g. Command and DataReader.
I know I can do this by creating the Command and DataReader, etc. classes that can contain switch statements that call the appropriate vendor specific calls, but I'd prefer to do something a bit more elegant. I sense that one of the standard design patterns may help, but I've yet to find an elegant solution. Any help would sure be appreciated.
Aucun commentaire:
Enregistrer un commentaire