@@ -7,6 +7,7 @@ public sealed class DatabaseDescription
77 readonly IReadOnlyDictionary < DbObjectId , Table > tableById ;
88 readonly IReadOnlyDictionary < DbObjectId , View > viewById ;
99 readonly IReadOnlyDictionary < string , Table > tableByQualifiedName ;
10+ readonly IReadOnlyDictionary < string , View > viewByQualifiedName ;
1011 public readonly ILookup < string , ForeignKey > ForeignKeyConstraintsByUnqualifiedName ;
1112 readonly ILookup < DbObjectId , ForeignKey > fksByReferencedParentObjectId ;
1213 readonly ILookup < DbObjectId , ForeignKey > fksByReferencingChildObjectId ;
@@ -23,6 +24,7 @@ public DatabaseDescription(RawDatabaseDescription rawDescription)
2324 fksByReferencedParentObjectId = fkObjects . ToLookup ( fk => fk . ReferencedParentTable . ObjectId ) ;
2425 fksByReferencingChildObjectId = fkObjects . ToLookup ( fk => fk . ReferencingChildTable . ObjectId ) ;
2526 tableByQualifiedName = tableById . Values . ToDictionary ( o => o . QualifiedName , StringComparer . OrdinalIgnoreCase ) ;
27+ viewByQualifiedName = viewById . Values . ToDictionary ( o => o . QualifiedName , StringComparer . OrdinalIgnoreCase ) ;
2628 ForeignKeyConstraintsByUnqualifiedName = fkObjects . ToLookup ( o => o . UnqualifiedName , StringComparer . OrdinalIgnoreCase ) ;
2729 }
2830
@@ -42,11 +44,14 @@ public Table GetTableByName(string qualifiedName)
4244 => TryGetTableByName ( qualifiedName ) ?? throw new ArgumentException ( $ "Unknown table '{ qualifiedName } '.", nameof ( qualifiedName ) ) ;
4345
4446 public Table ? TryGetTableByName ( string qualifiedName )
45- => tableByQualifiedName . TryGetValue ( qualifiedName , out var id ) ? id : null ;
47+ => tableByQualifiedName . TryGetValue ( qualifiedName , out var table ) ? table : null ;
4648
4749 public Table ? TryGetTableById ( DbObjectId id )
4850 => tableById . GetValueOrDefault ( id ) ;
4951
52+ public View ? TryGetViewByName ( string qualifiedName )
53+ => viewByQualifiedName . TryGetValue ( qualifiedName , out var view ) ? view : null ;
54+
5055 public sealed record ForeignKeyColumn ( Column < Table > ReferencedParentColumn , Column < Table > ReferencingChildColumn ) ;
5156
5257 public sealed class ForeignKey
0 commit comments