Class EntityAnalyzer
- Namespace
- ProjGraph.Lib.EntityFramework.Infrastructure
- Assembly
- ProjGraph.Lib.EntityFramework.dll
Provides methods for analyzing entity type symbols and extracting metadata such as properties, primary keys, and constraints. This class is implemented as a partial class to allow for extension in other files.
public static class EntityAnalyzer
- Inheritance
-
EntityAnalyzer
- Inherited Members
Methods
AnalyzeEntity(INamedTypeSymbol)
Analyzes the specified entity type symbol and extracts its properties, primary keys, and constraints.
public static EfEntity AnalyzeEntity(INamedTypeSymbol type)
Parameters
typeINamedTypeSymbolThe INamedTypeSymbol representing the entity type to analyze.
Returns
- EfEntity
An EfEntity object containing metadata about the entity, including its name and properties.
Remarks
This method traverses the inheritance hierarchy of the given entity type symbol to collect all properties. It skips navigation properties and ensures that each property is added only once. For each property, it determines whether it is a primary key, a foreign key, and applies any constraints.
FindEntitySymbol(EfEntity, Compilation)
Finds the entity symbol in the provided compilation that matches the name of the given EfEntity.
public static INamedTypeSymbol? FindEntitySymbol(EfEntity entity, Compilation compilation)
Parameters
entityEfEntityThe EfEntity containing the name of the entity to find.
compilationCompilationThe Compilation object to search for the entity symbol.
Returns
- INamedTypeSymbol
An INamedTypeSymbol representing the entity symbol if found; otherwise,
null.