Class DbContextIdentifier
- Namespace
- ProjGraph.Lib.EntityFramework.Infrastructure
- Assembly
- ProjGraph.Lib.EntityFramework.dll
Provides methods to identify and find DbContext classes within a collection of class declarations.
public static class DbContextIdentifier
- Inheritance
-
DbContextIdentifier
- Inherited Members
Methods
FindContextClass(IEnumerable<ClassDeclarationSyntax>, string?)
Finds a specific DbContext class by name or returns the first DbContext class in the collection.
public static ClassDeclarationSyntax? FindContextClass(IEnumerable<ClassDeclarationSyntax> classDeclarations, string? contextName)
Parameters
classDeclarationsIEnumerable<ClassDeclarationSyntax>A collection of class declarations to search.
contextNamestringThe name of the DbContext class to find. If
null, the first DbContext class is returned.
Returns
- ClassDeclarationSyntax
The ClassDeclarationSyntax of the matching DbContext class, or
nullif no match is found.
FindSnapshotClass(IEnumerable<ClassDeclarationSyntax>, string?)
Finds a specific ModelSnapshot class by name or returns the first ModelSnapshot class in the collection.
public static ClassDeclarationSyntax? FindSnapshotClass(IEnumerable<ClassDeclarationSyntax> classDeclarations, string? snapshotName)
Parameters
classDeclarationsIEnumerable<ClassDeclarationSyntax>A collection of class declarations to search.
snapshotNamestringThe name of the ModelSnapshot class to find. If
null, the first ModelSnapshot class is returned.
Returns
- ClassDeclarationSyntax
The ClassDeclarationSyntax of the matching ModelSnapshot class, or
nullif no match is found.
IsDbContext(ClassDeclarationSyntax)
Determines whether the specified class declaration represents a DbContext class.
public static bool IsDbContext(ClassDeclarationSyntax @class)
Parameters
classClassDeclarationSyntaxThe class declaration to check.
Returns
- bool
trueif the class declaration has a base type that contains "DbContext"; otherwise,false.
IsModelSnapshot(ClassDeclarationSyntax)
Determines whether the specified class declaration represents a ModelSnapshot class.
public static bool IsModelSnapshot(ClassDeclarationSyntax @class)
Parameters
classClassDeclarationSyntaxThe class declaration to check.
Returns
- bool
trueif the class declaration has a base type that contains "ModelSnapshot"; otherwise,false.