// get per thread cached db instance by name public DBMySqlDB getDB(string name) { DBMySqlDB db = null; ConcurrentDictionary <string, DBMySqlDB> dbs = null; // get current thread db instance dbs = _dbs.GetOrAdd(Thread.CurrentThread.ManagedThreadId, new ConcurrentDictionary <string, DBMySqlDB>()); dbs.TryGetValue(name, out db); if (db == null) { dynamic dbconf = null; _dbConfs.TryGetValue(name, out dbconf); if (dbconf == null) { // config not exist return(null); } db = new DBMySqlDB(); if (!db.init(dbconf)) { return(null); } dbs[name] = db; } return(db); }
// create a db instance outside manager, caller is response to maintain the instance public DBMySqlDB createDB(string name) { dynamic dbconf = null; DBMySqlDB db = null; _dbConfs.TryGetValue(name, dbconf); if (dbconf == null) { // config not exist return(null); } db = new DBMySqlDB(); if (!db.init(dbconf)) { return(null); } return(db); }
public AEDBPersistObject(object persistDB, IDBTable table, object memDB, string id, object data, bool isFromDB) : base(table, memDB, id, data, isFromDB) { _persistDB = (DBMySqlDB)persistDB; }