You can inherit from DBConnection, but the problem is you would need to implemented all of the inherited abstract members (of which there are 22).
You can inherit from DBConnection, but the problem is you would need to implemented all of the inherited abstract members (of which there are 22): public class MyConnect : DBConnection { public string FilePaths{ get; set; } //Still need to implement all of the } I'm assuming that you actually want to take advantage of the built in ADO classes that handle the implementation of DBConnection, so this is not a good option. Perhaps you just need to keep track of the information separately. Is there a particular reason why the information has to be part of the connection class?
You could do something along the lines of: public class MyConnectionInfo { public DBConnection Connection { get; set; } public string FileNames { get; set; } } This would put the information together but not complicate the usage of the DBConnection class.
The interface for the classes specify DBConnection as a parameter for the methods used in the classes : see edit in my Q at the top. – callisto Mar 7 at 14:50 Do you own those classes? If so, you make them accept anything you want.
If you don't, then just pass in the connection property. – RQDQ Mar 7 at 14:52 I do own the classes and the interface, but I want to present a unified interface for developers that will use this after me, which is why I used an interface to force the implementation of each data source's class methods. I am very open to other suggestions though.
– callisto Mar 7 at 14:56.
Make your class abstract too... public abstract class MyClass:System.Data.Common. DBConnect { abstract String ParameterString { get; set; } } If you don't wish your class to be abstract, then either inherit it from a concrete class, or override abstract methods. No third option here...
He would have to rewrite all of those to be able to connect to the data sources. – RQDQ Mar 7 at 14:24.
The DbConnection class is abstract, so you must implement all of its abstract methods. Here is what that looks like: protected override System.Data.Common. DbTransaction BeginDbTransaction(System.Data.
IsolationLevel isolationLevel) { throw new System. NotImplementedException(); } public override string ConnectionString { get { throw new System. NotImplementedException(); } set { throw new System.
NotImplementedException(); } } public override void ChangeDatabase(string databaseName) { throw new System. NotImplementedException(); } public override void Close() { throw new System. NotImplementedException(); } protected override System.Data.Common.
DbCommand CreateDbCommand() { throw new System. NotImplementedException(); } public override string DataSource { get { throw new System. NotImplementedException(); } } public override string Database { get { throw new System.
NotImplementedException(); } } public override void Open() { throw new System. NotImplementedException(); } public override string ServerVersion { get { throw new System. NotImplementedException(); } } public override System.Data.
ConnectionState State { get { throw new System. NotImplementedException(); } } Granted, you will have to put the correct logic in each of the methods that are throwing exceptions below. The ConnectionString property gives you an example on how to override a property.
If you need an additional property you can add it as you would any other property to a C# class.
Thanks Dan. Have an upvote too! :) – callisto Mar 7 at 14:48.
Thanks to RQDQ: I finally used the following class to do what I needed: public class GenericConnection { public GenericConnection(){} public DbConnection DBConn { get; set; } public string Filename { get; set; } } As you can see, I added the System.Data.Common. DBConnect as an attribute, and added the string attribute I needed too.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.