internal void CloseConnection() { if (_dbConnection != null && !_dbConnection.IsClosed()) { _dbConnection.Close(); } _dbConnection = null; }
protected internal override CSSchemaColumn[] GetSchemaColumns(string tableName) { using (ICSDbConnection newConn = CreateConnection()) { ICSDbCommand dbCommand = newConn.CreateCommand(); dbCommand.CommandText = "select * from " + QuoteTable(tableName); using (var dataReader = (CSSqlReader)dbCommand.ExecuteReader(CSCommandBehavior.SchemaOnly | CSCommandBehavior.KeyInfo)) { var schemaColumns = new List <CSSchemaColumn>(); DataTable schemaTable = dataReader.Reader.GetSchemaTable(); bool hasHidden = schemaTable.Columns.Contains("IsHidden"); bool hasIdentity = schemaTable.Columns.Contains("IsIdentity"); bool hasAutoincrement = schemaTable.Columns.Contains("IsAutoIncrement"); foreach (DataRow schemaRow in schemaTable.Rows) { var schemaColumn = new CSSchemaColumn(); if (hasHidden && !schemaRow.IsNull("IsHidden") && (bool)schemaRow["IsHidden"]) { schemaColumn.Hidden = true; } if (hasIdentity && !schemaRow.IsNull("IsIdentity") && (bool)schemaRow["IsIdentity"]) { schemaColumn.Identity = true; } schemaColumn.IsKey = (bool)schemaRow["IsKey"]; schemaColumn.AllowNull = (bool)schemaRow["AllowDBNull"]; schemaColumn.Name = (string)schemaRow["ColumnName"]; schemaColumn.ReadOnly = (bool)schemaRow["IsReadOnly"]; schemaColumn.DataType = (Type)schemaRow["DataType"]; schemaColumn.Size = (int)schemaRow["ColumnSize"]; if (hasAutoincrement && !schemaRow.IsNull("IsAutoIncrement") && (bool)schemaRow["IsAutoIncrement"]) { schemaColumn.Identity = true; } schemaColumns.Add(schemaColumn); } return(schemaColumns.ToArray()); } } }
public void Dispose() { if (_disposed) { return; } if (_dbConnection != null && !_dbConnection.IsClosed()) { _dbConnection.Close(); } _dbConnection = null; _disposed = true; }
protected internal override CSSchemaColumn[] GetSchemaColumns(string tableName) { using (ICSDbConnection newConn = CreateConnection()) { List <CSSchemaColumn> columns = new List <CSSchemaColumn>(); DataTable schemaTable = ((CSSqliteConnection)newConn).GetSchema(tableName); bool hasHidden = schemaTable.Columns.Contains("IsHidden"); bool hasIdentity = schemaTable.Columns.Contains("IsIdentity"); bool hasAutoincrement = schemaTable.Columns.Contains("IsAutoIncrement"); foreach (DataRow schemaRow in schemaTable.Rows) { CSSchemaColumn schemaColumn = new CSSchemaColumn(); if (hasHidden && !schemaRow.IsNull("IsHidden") && (bool)schemaRow["IsHidden"]) { schemaColumn.Hidden = true; } schemaColumn.IsKey = (bool)schemaRow["IsKey"]; schemaColumn.AllowNull = (bool)schemaRow["AllowDBNull"]; schemaColumn.Name = (string)schemaRow["ColumnName"]; schemaColumn.ReadOnly = (bool)schemaRow["IsReadOnly"]; schemaColumn.DataType = (Type)schemaRow["DataType"]; schemaColumn.Size = (int)schemaRow["ColumnSize"]; if (hasAutoincrement && !schemaRow.IsNull("IsAutoIncrement") && (bool)schemaRow["IsAutoIncrement"]) { schemaColumn.Identity = true; } if (hasIdentity && !schemaRow.IsNull("IsIdentity") && (bool)schemaRow["IsIdentity"]) { schemaColumn.Identity = true; } columns.Add(schemaColumn); } return(columns.ToArray()); } }
public void Dispose() { if (_disposed) return; if (_dbConnection != null && !_dbConnection.IsClosed()) _dbConnection.Close(); _dbConnection = null; _disposed = true; }
internal void CloseConnection() { if (_dbConnection != null && !_dbConnection.IsClosed()) _dbConnection.Close(); _dbConnection = null; }