In the method below, if we have the same table/view created in two different schemas, a "An item with the same key has already been added." error will be thrown.
In private static void ApplyColumnData(IDatabaseSession session, List tables) method, change the following code from:
string sql = session.Build().Query("INFORMATION_SCHEMA.COLUMNS").Select("TABLE_NAME", "COLUMN_NAME", "COLUMN_DEFAULT", "IS_NULLABLE", "DATA_TYPE", "CHARACTER_MAXIMUM_LENGTH").ToSql();
IDataMapper<ColumnDescriptor> mapper = DataMapperFactory.Create<ColumnDescriptor>((Func<DataMapperFactory.ITranslator, ColumnDescriptor>) (x =>
{
string index = x.String("TABLE_NAME");
to
string sql = session.Build().Query("INFORMATION_SCHEMA.COLUMNS").Select("TABLE_SCHEMA" ,"TABLE_NAME", "COLUMN_NAME", "COLUMN_DEFAULT", "IS_NULLABLE", "DATA_TYPE", "CHARACTER_MAXIMUM_LENGTH").ToSql();
IDataMapper mapper = DataMapperFactory.Create((Func<DataMapperFactory.ITranslator, ColumnDescriptor>) (x =>
{
string index = x.String("TABLE_SCHEMA") + x.String("TABLE_NAME");
Error Details:
Fatal Error:
An item with the same key has already been added.
Trace:
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable
1 source, Func2 keySelector, Func
2 elementSelector, IEqualityCompare
at System.Linq.Enumerable.ToDictionary[TSource,TKey](IEnumerable1 source, Func
2 keySelector)
at Skele.Interop.SqlServer.MetadataFactory.ApplyColumnData(IDatabaseSession session, List1 tables) at Skele.Interop.SqlServer.MetadataFactory.Create(IDatabaseSession session) at Skele.Interop.SqlServer.SqlServerSession.Describe() at Skele.Scripting.ExecuteCommandHandler.Execute(ExecuteCommand input) at Skele.Core.DefaultCommandDispatcher.Dispatch[T](T command) at Skele.Core.InputAdapter.CommandTransform
1.Apply(String[] input)
at Skele.Core.InputAdapter.Apply(String[] input)
at Skele.Program.Run(String[] args)