All pastes #800798 Raw Edit

Something

public text v1 · immutable
#800798 ·published 2007-11-28 19:32 UTC
rendered paste body
 public class DbFactory<T, V> 
        where T : IDbConnection 
        where V : IDbCommand
    {
        public static DbFactory<T, V> Create(string connectionString)
        {
            DbFactory<T, V> db = new DbFactory<T, V>();
            db._connection = Activator.CreateInstance<T>();
            db._connection.ConnectionString = connectionString;
            db._commandFactory.DbFactory = db;

            return db;
        }

        private DbCommandFactory<V, T> _commandFactory;
        private IDbConnection _connection;
        
        public IDbConnection Connection
        {
            get { return _connection; }
            set { _connection = value; }
        }

        public DbCommandFactory<V, T> CommandFactory
        {
            get { return _commandFactory; }
        }

        internal DbFactory()
        {
            _commandFactory = new DbCommandFactory<V, T>();
        }
    }