Table of Contents

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

classDeclarations IEnumerable<ClassDeclarationSyntax>

A collection of class declarations to search.

contextName string

The 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 null if 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

classDeclarations IEnumerable<ClassDeclarationSyntax>

A collection of class declarations to search.

snapshotName string

The 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 null if no match is found.

IsDbContext(ClassDeclarationSyntax)

Determines whether the specified class declaration represents a DbContext class.

public static bool IsDbContext(ClassDeclarationSyntax @class)

Parameters

class ClassDeclarationSyntax

The class declaration to check.

Returns

bool

true if 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

class ClassDeclarationSyntax

The class declaration to check.

Returns

bool

true if the class declaration has a base type that contains "ModelSnapshot"; otherwise, false.