internal void PopulateArray(DataTable metaData, NameValueCollection map) { if (map != null) { BindToColumnsCustom(metaData, map); } else { BindToColumns(metaData); } ForeignKey key = null; string keyName = ""; foreach (DataRowView rowView in metaData.DefaultView) { try { DataRow row = rowView.Row; keyName = row[f_FKName] as string; key = this.GetByName(keyName); if (null == key) { key = (ForeignKey)this.dbRoot.ClassFactory.CreateForeignKey(); key.dbRoot = this.dbRoot; key.ForeignKeys = this; key.Row = row; this._array.Add(key); } string catalog = (DBNull.Value == row[f_PKTableCatalog]) ? string.Empty : (row[f_PKTableCatalog] as string); string schema = (DBNull.Value == row[f_PKTableSchema]) ? string.Empty : (row[f_PKTableSchema] as string); key.AddForeignColumn(catalog, schema, (string)row[f_PKTableName], (string)row["PK_COLUMN_NAME"], true); catalog = (DBNull.Value == row[f_FKTableCatalog]) ? string.Empty : (row[f_FKTableCatalog] as string); schema = (DBNull.Value == row[f_FKTableSchema]) ? string.Empty : (row[f_FKTableSchema] as string); key.AddForeignColumn(catalog, schema, (string)row[f_FKTableName], (string)row["FK_COLUMN_NAME"], false); } catch {} } }
internal void PopulateArray(DataTable metaData) { BindToColumns(metaData); ForeignKey key = null; string keyName = ""; foreach (DataRowView rowView in metaData.DefaultView) { try { DataRow row = rowView.Row; keyName = row["FK_NAME"] as string; key = this.GetByName(keyName); if (null == key) { key = (ForeignKey)this.dbRoot.ClassFactory.CreateForeignKey(); key.dbRoot = this.dbRoot; key.ForeignKeys = this; key.Row = row; this._array.Add(key); } string catalog = (DBNull.Value == row["PK_TABLE_CATALOG"]) ? string.Empty : (row["PK_TABLE_CATALOG"] as string); string schema = (DBNull.Value == row["PK_TABLE_SCHEMA"]) ? string.Empty : (row["PK_TABLE_SCHEMA"] as string); key.AddForeignColumn(catalog, schema, (string)row["PK_TABLE_NAME"], (string)row["PK_COLUMN_NAME"], true); catalog = (DBNull.Value == row["FK_TABLE_CATALOG"]) ? string.Empty : (row["FK_TABLE_CATALOG"] as string); schema = (DBNull.Value == row["FK_TABLE_SCHEMA"]) ? string.Empty : (row["FK_TABLE_SCHEMA"] as string); key.AddForeignColumn(catalog, schema, (string)row["FK_TABLE_NAME"], (string)row["FK_COLUMN_NAME"], false); } catch {} } }