Howard  Yu
Howard Yu

Reputation: 311

Database connector interface to implement in c#

Hi I am a new developer to c# and I am trying to implement a connector to a database using native c#. I am wondering if there are some "standard" interface (like JDBC in java, ODBC in c) to implement so that c# developer can use to connect to database.

I do notice some interfaces and abstract classes like https://msdn.microsoft.com/en-us/library/system.data.common.dbconnection(v=vs.110).aspx.

I am not sure if I should directly implement IDbConnection interface or I should extends the abstract class DbConnection. Also is there a complete list of interfaces so that I can claim my driver support certain version of apis.

One last question, I looked at Mysql connector for .net and seems there area not implementing/extending those interfaces/classes. https://github.com/mysql/mysql-connector-net/blob/6.9/Source/MySql.Data/Connection.cs Is there a reason why Mysql did not do it? It makes me feel those interfaces are not standard.

Upvotes: 0

Views: 1002

Answers (1)

ali
ali

Reputation: 1351

I think inheriting DbConnection and implementing ICloneable will be sufficient. If you look at the MySql sources carefully you will see that DbConnection and ICloneable are inherited and implemented by the partial class of MySqlConnection which is in here.

Upvotes: 1

Related Questions