I just found a bug in the new version of SchemaExplorer (184.108.40.2067) at MemberColumnSchemaCollection.Contains(CoolumnSchema value) method.
How to reproduce:
SqlSchemaProvider p = new SqlSchemaProvider();
DatabaseSchema db = new DatabaseSchema(p, “your-connection-string”);
TableSchema table = db.Tables[“E_AWBs”];
// Returns true
bool isFound = Test(table.Columns[“FlightNO”]);
// Returns false – in the previous version it worked just fine
bool isFoundTPK = Test(table.PrimaryKey.MemberColumns[“FlightNO”]);
public static bool Test(ColumnSchema column)
TableSchema tbl = column.Table;
foreach (TableKeySchema key in tbl.ForeignKeys)
I’m not sure how the code is written (the reflector shows me the message “This item appears to be obfuscated and can not be translated“) but my guess is that table.PrimaryKey.Columns return a shallow copy of table.Columns and therefore the Contains method don’t work properly.
- The quick solution is quite dirty but is simple and match the same solution I did before:
column = column.Table.Columns[column.Name]; // Change the pointer to address the real column
- The other solution is to foreach the key.ForeignKeyMemberColumns and match column name and table name as needed.
I’ll open a bug(I’m not sure it’s the right definition) at CodeSmith support forum.
Just got an answer from Eric J. Smith “This issue should be resolved for the next maintenance release.”