private void InitForeignKeys(IDataBaseSchema meta) { foreach (DataRow row in meta.GetForeignKeys(catalog, schema, name).Rows) { AddForeignKey(row, meta); } }
/// <summary> /// Inicializa os indices da instancia. /// </summary> /// <param name="meta"></param> private void InitIndexes(IDataBaseSchema meta) { foreach (System.Data.DataRow row in meta.GetIndexInfo(_catalog, _schema, _name).Rows) { AddIndex(row, meta); } }
private void InitIndexes(IDataBaseSchema meta) { foreach (DataRow row in meta.GetIndexInfo(catalog, schema, name).Rows) { AddIndex(row, meta); } }
/// <summary> /// Inicializa as colunas da instancia. /// </summary> /// <param name="meta"></param> private void InitColumns(IDataBaseSchema meta) { foreach (System.Data.DataRow row in meta.GetColumns(_catalog, _schema, _name, null).Rows) { AddColumn(row); } }
/// <summary> /// Inicializa as chaves estrangeiras da instancia. /// </summary> /// <param name="meta"></param> private void InitForeignKeys(IDataBaseSchema meta) { foreach (System.Data.DataRow row in meta.GetForeignKeys(_catalog, _schema, _name).Rows) { AddForeignKey(row, meta); } }
private void InitColumns(IDataBaseSchema meta) { foreach (DataRow row in meta.GetColumns(catalog, schema, name, null).Rows) { AddColumn(row); } }
public DatabaseMetadata(DbConnection connection, Dialect.Dialect dialect, bool extras) { meta = dialect.GetDataBaseSchema(connection); this.dialect = dialect; this.extras = extras; InitSequences(connection, dialect); sqlExceptionConverter = dialect.BuildSQLExceptionConverter(); }
public BaseTableMetadata(System.Data.DataRow rs, IDataBaseSchema meta, bool extras) { this.ParseTableInfo(rs); this.InitColumns(meta); if (extras) { this.InitForeignKeys(meta); this.InitIndexes(meta); } }
public static TableEnumerator GetInstance(IDataBaseSchema schema) { if (null == Configuration) { throw new InvalidOperationException("Configuration not initialized"); } if (null == instance) { instance = new TableEnumerator(); } instance.Schema = schema; return(instance); }
public AbstractTableMetadata(DataRow rs, IDataBaseSchema meta, bool extras) { ParseTableInfo(rs); InitColumns(meta); if (extras) { InitForeignKeys(meta); InitIndexes(meta); } string cat = catalog == null ? "" : catalog + '.'; string schem = schema == null ? "" : schema + '.'; log.Info("table found: " + cat + schem + name); log.Info("columns: " + StringHelper.CollectionToString(columns.Keys)); if (extras) { log.Info("foreign keys: " + StringHelper.CollectionToString(foreignKeys.Keys)); log.Info("indexes: " + StringHelper.CollectionToString(indexes.Keys)); } }
/// <summary> /// Adiciona um indice para a instancia. /// </summary> /// <param name="rs"></param> /// <param name="meta"></param> private void AddIndex(System.Data.DataRow rs, IDataBaseSchema meta) { string index = GetIndexName(rs); if (string.IsNullOrEmpty(index)) { return; } IIndexMetadata info = GetIndexMetadata(index); if (info == null) { info = GetIndexMetadata(rs); _indexes[info.Name.ToLowerInvariant()] = info; } foreach (System.Data.DataRow row in meta.GetIndexColumns(_catalog, _schema, _name, index).Rows) { info.AddColumn(GetColumnMetadata(GetColumnName(row))); } }
/// <summary> /// Adiciona uma chave estrangeira para a instancia. /// </summary> /// <param name="rs">Linha que contem</param> /// <param name="meta"></param> private void AddForeignKey(System.Data.DataRow rs, IDataBaseSchema meta) { string fk = GetConstraintName(rs); if (string.IsNullOrEmpty(fk)) { return; } IForeignKeyMetadata info = GetForeignKeyMetadata(fk); if (info == null) { info = GetForeignKeyMetadata(rs); _foreignKeys[info.Name.ToLowerInvariant()] = info; } foreach (System.Data.DataRow row in meta.GetIndexColumns(_catalog, _schema, _name, fk).Rows) { info.AddColumn(GetColumnMetadata(GetColumnName(row))); } }
private void AddForeignKey(DataRow rs, IDataBaseSchema meta) { string fk = GetConstraintName(rs); if (string.IsNullOrEmpty(fk)) { return; } IForeignKeyMetadata info = GetForeignKeyMetadata(fk); if (info == null) { info = GetForeignKeyMetadata(rs); foreignKeys[info.Name] = info; } foreach (DataRow row in meta.GetIndexColumns(catalog, schema, name, fk).Rows) { info.AddColumn(GetColumnMetadata(GetColumnName(row))); } }
private void AddIndex(DataRow rs, IDataBaseSchema meta) { string index = GetIndexName(rs); if (string.IsNullOrEmpty(index)) { return; } IIndexMetadata info = GetIndexMetadata(index); if (info == null) { info = GetIndexMetadata(rs); indexes[info.Name] = info; } foreach (DataRow row in meta.GetIndexColumns(catalog, schema, name, index).Rows) { info.AddColumn(GetColumnMetadata(GetColumnName(row))); } }
public void InquireSchema() { Dialect.MsSql2005Dialect dialect = new MsSql2005Dialect(); DbConnection conn = new SqlConnection(@""); conn.Open(); DatabaseMetadata meta = new DatabaseMetadata(conn, dialect); IDataBaseSchema schema = dialect.GetDataBaseSchema(conn); var dt = schema.GetTables(null, null, null, new string[0]); var cols = schema.GetColumns(null, null, null, null); var keys = schema.GetForeignKeys(null, null, null); foreach (DataRow r in dt.Rows) { var tableMeta = schema.GetTableMetadata(r, true); Console.WriteLine(string.Format("Table {2}:[{0}].[{1}]", tableMeta.Schema, tableMeta.Name, tableMeta.Catalog)); ITableMetadata tm = meta.GetTableMetadata(tableMeta.Name, tableMeta.Schema, tableMeta.Catalog, false); IColumnMetadata col = tm.GetColumnMetadata(cols.Rows[0].ItemArray[2] as string); } }
public MsSqlTableMetadata(DataRow rs, IDataBaseSchema meta, bool extras) : base(rs, meta, extras) { }
public ChillowMySqlTableMetadata(DataRow rs, IDataBaseSchema meta, bool extras) : base(rs, meta, extras) { }
public PostgreSQLTableMetadata(DataRow rs, IDataBaseSchema meta, bool extras) : base(rs, meta, extras) { }
public SybaseAnywhereTableMetaData(DataRow rs, IDataBaseSchema meta, bool extras) : base(rs, meta, extras) { }
public FirebirdTableMetadata(DataRow rs, IDataBaseSchema meta, bool extras) : base(rs, meta, extras) { }
public SQLiteTableMetaData(DataRow rs, IDataBaseSchema meta, bool extras) : base(rs, meta, extras) {}
public SybaseAnywhereTableMetaData(DataRow rs, IDataBaseSchema meta, bool extras) : base(rs, meta, extras) {}
private void AddForeignKey(DataRow rs, IDataBaseSchema meta) { string fk = GetConstraintName(rs); if (string.IsNullOrEmpty(fk)) return; IForeignKeyMetadata info = GetForeignKeyMetadata(fk); if (info == null) { info = GetForeignKeyMetadata(rs); foreignKeys[info.Name.ToLowerInvariant()] = info; } foreach (DataRow row in meta.GetIndexColumns(catalog, schema, name, fk).Rows) { info.AddColumn(GetColumnMetadata(GetColumnName(row))); } }
public OracleTableMetadata(DataRow rs, IDataBaseSchema meta, bool extras) : base(rs, meta, extras) { }
public DB2TableMetaData(DataRow rs, IDataBaseSchema meta, bool extras) : base(rs, meta, extras) { }
private void AddIndex(DataRow rs, IDataBaseSchema meta) { string index = GetIndexName(rs); if (string.IsNullOrEmpty(index)) return; IIndexMetadata info = GetIndexMetadata(index); if (info == null) { info = GetIndexMetadata(rs); indexes[info.Name.ToLowerInvariant()] = info; } foreach (DataRow row in meta.GetIndexColumns(catalog, schema, name, index).Rows) { info.AddColumn(GetColumnMetadata(GetColumnName(row))); } }