I am using ADO.NET interfaces to create a database independent program. The factory takes in a provider name and returns vendor specific objects which implement the ADO interface. This is great.
But I can’t find a factory for the flag which identifies a parameter.
string paramName = "@foo"; //flag "@" for sql server
string paramName = ":foo"; //flag ":" for oracle
Question: Does ADO.NET provide a factory method to obtain the flag?
I could roll my own separate factory for this, but it would limit me to a predefined list of providers; defeating much of the benefit of the provider factory.
Unfortunately, the DbProviderFactory mechanism is very poorly designed IMHO.
The mechanism itself is not extensible, all the interesting classes are sealed (SqlClientFactory, etc.), the configuration in the .config file is not extensible either.
One simple solution is to build an extension class, like this:
It’s not very smart, but you can do this in your code:
Or you could also recreate your own system. It’s not very complicated, and can be worth it if you need other variable items per type of database.