fluent-nhibernate
fluent-nhibernate copied to clipboard
Duplicate join exception thrown even with tables coming from different schemas/catalogs
Here is an example explaining the issue:
When we do the following :
Join("tablename", join => { join.Schema("schema1").Catalog("catalog1"); join.Optional(); join.KeyColumn("somekeycolumn"); });
Join("tablename", join => { join.Schema("schema2").Catalog("catalog2"); join.Optional(); join.KeyColumn("somekeycolumn"); });
Fluent throws an exception : if (joins.Exists(x => x.TableName == mapping.TableName) throw new InvalidOperationException("Tried to add join to table '" + mapping.TableName + "' when already added.");
The check should look more like :
if (joins.Exists(x => x.TableName == mapping.TableName && x.Schema == mapping.Schema && x.Catalog == mapping.Catalog))