Class ValueGeneratorSelector
- Namespace
- Microsoft.EntityFrameworkCore.ValueGeneration
- Assembly
- Microsoft.EntityFrameworkCore.dll
Selects value generators to be used to generate values for properties of entities.
This type is typically used by database providers (and other extensions). It is generally not used in application code.
public class ValueGeneratorSelector : IValueGeneratorSelector
- Inheritance
-
ValueGeneratorSelector
- Implements
- Inherited Members
Remarks
The service lifetime is Scoped. This means that each DbContext instance will use its own instance of this service. The implementation may depend on other services registered with any lifetime. The implementation does not need to be thread-safe.
See Implementation of database providers and extensions for more information and examples.
Constructors
ValueGeneratorSelector(ValueGeneratorSelectorDependencies)
Initializes a new instance of the ValueGeneratorSelector class.
public ValueGeneratorSelector(ValueGeneratorSelectorDependencies dependencies)
Parameters
dependencies
ValueGeneratorSelectorDependenciesParameter object containing dependencies for this service.
Properties
Cache
The cache being used to store value generator instances.
public virtual IValueGeneratorCache Cache { get; }
Property Value
Dependencies
Dependencies for this service.
protected virtual ValueGeneratorSelectorDependencies Dependencies { get; }
Property Value
Methods
Create(IProperty, ITypeBase)
Creates a new value generator for the given property.
public virtual ValueGenerator Create(IProperty property, ITypeBase typeBase)
Parameters
property
IPropertyThe property to get the value generator for.
typeBase
ITypeBaseThe entity type that the value generator will be used for. When called on inherited properties on derived entity types, this entity type may be different from the declared entity type on
property
Returns
- ValueGenerator
The newly created value generator.
FindForType(IProperty, ITypeBase, Type)
Creates a new value generator for the given property and type, where the property may have a ValueConverter.
protected virtual ValueGenerator? FindForType(IProperty property, ITypeBase typeBase, Type clrType)
Parameters
property
IPropertyThe property to get the value generator for.
typeBase
ITypeBaseThe entity type that the value generator will be used for. When called on inherited properties on derived entity types, this entity type may be different from the declared entity type on
property
clrType
TypeThe type, which may be the provider type after conversion, rather than the property type.
Returns
- ValueGenerator
The newly created value generator.
Select(IProperty, ITypeBase)
Selects the appropriate value generator for a given property.
public virtual ValueGenerator Select(IProperty property, ITypeBase typeBase)
Parameters
property
IPropertyThe property to get the value generator for.
typeBase
ITypeBaseThe entity type that the value generator will be used for. When called on inherited properties on derived entity types, this entity type may be different from the declared entity type on
property
Returns
- ValueGenerator
The value generator to be used.