1
namespace AV.Connections
{
protected class MyConnection
{
protected ConnectionStringSettings connectionSettings
{
get { return ConfigurationManager.ConnectionStrings["mySQLConnection"]; }
}
protected DbConnection connection
{
get { return new OdbcConnection(connectionSettings.ConnectionString); }
}
protected DbCommand command
{
get { return connection.CreateCommand(); }
}
protected DbParameter parameter
{
get { return command.CreateParameter(); }
}
}
}
我试图创建单身类,它可以返回连接对象以及其他相关对象。以上是我想到的方法。不知何故,我确信我错了。请指出如何?或者,如果不是,这是最好的方法。单杠连接类
这不是单身....我明白,但我认为我不能声明静态类,因为它涉及到连接。所以我对这种情况非常困惑。