/// <summary> /// Initializes a new instance of the TableBase class. /// </summary> /// <param name="connection">The connection the table is opened against.</param> /// <param name="table">The name of the table to open.</param> protected TableBase(ConnectionBase connection, string table) { this.Tracer = new Tracer("Table", "Esent Table", String.Format("Table {0}", table)); this.Connection = connection; this.tablename = table; this.recordsWithOpenCursor = new List<Record>(); this.tableCursor = this.OpenCursor(); this.CursorCache = new CursorCache<Cursor>(this.OpenCursor, this.CloseCursor, this.TableName, 4); this.LoadMetaData(); this.Tracer.TraceInfo("opened"); }
/// <summary> /// Called when a connection is closed. This removes the connection from the list of /// connections and terminates the instance if necessary. /// </summary> /// <param name="connection">The connection being closed.</param> private void OnConnectionClose(ConnectionBase connection) { lock (this.lockObject) { connection.Disposed -= this.OnConnectionClose; this.Tracer.TraceVerbose("closing connection '{0}' (database '{1}')", connection.Name, connection.Database); string database = connection.Database; this.instances[database].Connections.Remove(connection); this.Tracer.TraceVerbose("database '{0}' has {1} connections left", database, this.instances[database].Connections.Count); if (0 == this.instances[database].Connections.Count()) { this.Tracer.TraceInfo("no connections left to database '{0}'. Terminating ese", database); // all connections are closed, terminate the instance this.instances[database].Instance.Term(); this.instances.Remove(database); } } }
/// <summary> /// Initializes a new instance of the ReadOnlyTable class. /// </summary> /// <param name="connection">The connection the table is opened against.</param> /// <param name="table">The name of the table to open.</param> public ReadOnlyTable(ConnectionBase connection, string table) : base(connection, table) { this.Tracer.TraceInfo("read-only"); }
/// <summary> /// Initializes a new instance of the ReadOnlyTable class. /// </summary> /// <param name="connection">The connection the table is opened against.</param> /// <param name="table">The name of the table to open.</param> public ReadOnlyTable(ConnectionBase connection, string table) : base(connection, table) { this.Tracer.TraceInfo("read-only"); }