@@ -592,7 +592,7 @@ FROM [sys].[views] AS [v]
592592WHERE "
593593 + viewFilter ;
594594
595- command . CommandText = commandText + viewCommandText ;
595+ command . CommandText = SupportsViews ( ) ? commandText + viewCommandText : commandText ;
596596
597597 using ( var reader = command . ExecuteReader ( ) )
598598 {
@@ -646,7 +646,12 @@ FROM [sys].[views] AS [v]
646646
647647 // This is done separately due to MARS property may be turned off
648648 GetColumns ( connection , tables , filter , viewFilter , typeAliases , databaseCollation ) ;
649- GetIndexes ( connection , tables , filter ) ;
649+
650+ if ( SupportsIndexes ( ) )
651+ {
652+ GetIndexes ( connection , tables , filter ) ;
653+ }
654+
650655 GetForeignKeys ( connection , tables , filter ) ;
651656 GetTriggers ( connection , tables , filter ) ;
652657
@@ -685,14 +690,19 @@ private void GetColumns(
685690 [c].[collation_name],
686691 [c].[is_sparse]
687692FROM
688- (
693+ (" ;
694+ if ( SupportsViews ( ) )
695+ {
696+ commandText += @"
689697 SELECT[v].[name], [v].[object_id], [v].[schema_id]
690698 FROM [sys].[views] v WHERE " ;
691699
692- commandText += viewFilter ;
700+ commandText += viewFilter ;
693701
702+ commandText += @"
703+ UNION ALL" ;
704+ }
694705 commandText += @"
695- UNION ALL
696706 SELECT [t].[name], [t].[object_id], [t].[schema_id]
697707 FROM [sys].[tables] t WHERE " ;
698708
@@ -1156,14 +1166,17 @@ private void GetForeignKeys(DbConnection connection, IReadOnlyList<DatabaseTable
11561166 SCHEMA_NAME([t].[schema_id]) AS [table_schema],
11571167 [t].[name] AS [table_name],
11581168 [f].[name],
1159- OBJECT_SCHEMA_NAME([f].[referenced_object_id]) AS [principal_table_schema],
1160- OBJECT_NAME([f].[referenced_object_id]) AS [principal_table_name],
1161- [f].[delete_referential_action_desc],
1162- col_name([fc].[parent_object_id], [fc].[parent_column_id]) AS [column_name],
1163- col_name([fc].[referenced_object_id], [fc].[referenced_column_id]) AS [referenced_column_name]
1164- FROM [sys].[foreign_keys] AS [f]
1165- JOIN [sys].[tables] AS [t] ON [f].[parent_object_id] = [t].[object_id]
1166- JOIN [sys].[foreign_key_columns] AS [fc] ON [f].[object_id] = [fc].[constraint_object_id]
1169+ SCHEMA_NAME(tab2.[schema_id]) AS [principal_table_schema],
1170+ [tab2].name AS [principal_table_name],
1171+ [f].[delete_referential_action_desc],
1172+ [col1].[name] AS [column_name],
1173+ [col2].[name] AS [referenced_column_name]
1174+ FROM [sys].[foreign_keys] AS [f]
1175+ JOIN [sys].[foreign_key_columns] AS fc ON [fc].[constraint_object_id] = [f].[object_id]
1176+ JOIN [sys].[tables] AS [t] ON [t].[object_id] = [fc].[parent_object_id]
1177+ JOIN [sys].[columns] AS [col1] ON [col1].[column_id] = [fc].[parent_column_id] AND [col1].[object_id] = [t].[object_id]
1178+ JOIN [sys].[tables] AS [tab2] ON [tab2].[object_id] = [fc].[referenced_object_id]
1179+ JOIN [sys].[columns] AS [col2] ON [col2].[column_id] = [fc].[referenced_column_id] AND [col2].[object_id] = [tab2].[object_id]
11671180WHERE "
11681181 + tableFilter
11691182 + @"
@@ -1335,13 +1348,19 @@ FROM [sys].[triggers] AS [tr]
13351348 }
13361349
13371350 private bool SupportsTemporalTable ( )
1338- => _compatibilityLevel >= 130 && _engineEdition != 6 ;
1351+ => _compatibilityLevel >= 130 && ( _engineEdition is not 6 and not 11 and not 1000 ) ;
13391352
13401353 private bool SupportsMemoryOptimizedTable ( )
1341- => _compatibilityLevel >= 120 && _engineEdition != 6 ;
1354+ => _compatibilityLevel >= 120 && ( _engineEdition is not 6 and not 11 and not 1000 ) ;
13421355
13431356 private bool SupportsSequences ( )
1344- => _compatibilityLevel >= 110 && _engineEdition != 6 ;
1357+ => _compatibilityLevel >= 110 && ( _engineEdition is not 6 and not 11 and not 1000 ) ;
1358+
1359+ private bool SupportsIndexes ( )
1360+ => _engineEdition != 1000 ;
1361+
1362+ private bool SupportsViews ( )
1363+ => _engineEdition != 1000 ;
13451364
13461365 private static string DisplayName ( string ? schema , string name )
13471366 => ( ! string . IsNullOrEmpty ( schema ) ? schema + "." : "" ) + name ;
0 commit comments