public void GetCursorWithImplicitTxn(string home, string dbFile, bool ifConfig) { DatabaseEnvironmentConfig envConfig = new DatabaseEnvironmentConfig(); envConfig.Create = true; envConfig.UseCDB = true; envConfig.UseMPool = true; DatabaseEnvironment env = DatabaseEnvironment.Open( home, envConfig); RecnoDatabaseConfig dbConfig = new RecnoDatabaseConfig(); dbConfig.Creation = CreatePolicy.IF_NEEDED; dbConfig.Env = env; RecnoDatabase db = RecnoDatabase.Open(dbFile, dbConfig); RecnoCursor cursor; if (ifConfig == false) { cursor = db.Cursor(); } else { cursor = db.Cursor(new CursorConfig()); } cursor.Close(); db.Close(); env.Close(); }
public void GetCursorWithExplicitTxn(string home, string dbFile, bool ifConfig) { DatabaseEnvironmentConfig envConfig = new DatabaseEnvironmentConfig(); envConfig.Create = true; envConfig.UseTxns = true; envConfig.UseMPool = true; DatabaseEnvironment env = DatabaseEnvironment.Open( home, envConfig); Transaction openTxn = env.BeginTransaction(); RecnoDatabaseConfig dbConfig = new RecnoDatabaseConfig(); dbConfig.Creation = CreatePolicy.IF_NEEDED; dbConfig.Env = env; RecnoDatabase db = RecnoDatabase.Open(dbFile, dbConfig, openTxn); openTxn.Commit(); Transaction cursorTxn = env.BeginTransaction(); RecnoCursor cursor; if (ifConfig == false) { cursor = db.Cursor(cursorTxn); } else { cursor = db.Cursor(new CursorConfig(), cursorTxn); } cursor.Close(); cursorTxn.Commit(); db.Close(); env.Close(); }