Class ValueGeneratorCache
- Namespace
- Microsoft.EntityFrameworkCore.ValueGeneration
- Assembly
- Microsoft.EntityFrameworkCore.dll
Keeps a cache of value generators for properties.
This type is typically used by database providers (and other extensions). It is generally not used in application code.
public class ValueGeneratorCache : IValueGeneratorCache
- Inheritance
-
ValueGeneratorCache
- Implements
- Inherited Members
Remarks
The service lifetime is Singleton. This means a single instance is used by many DbContext instances. The implementation must be thread-safe. This service cannot depend on services registered as Scoped.
See Implementation of database providers and extensions for more information and examples.
Constructors
ValueGeneratorCache(ValueGeneratorCacheDependencies)
Initializes a new instance of the ValueGeneratorCache class.
public ValueGeneratorCache(ValueGeneratorCacheDependencies dependencies)
Parameters
dependencies
ValueGeneratorCacheDependenciesParameter object containing dependencies for this service.
Properties
Dependencies
Dependencies for this service.
protected virtual ValueGeneratorCacheDependencies Dependencies { get; }
Property Value
Methods
GetOrAdd(IProperty, ITypeBase, Func<IProperty, ITypeBase, ValueGenerator>)
Gets the existing value generator from the cache, or creates a new one if one is not present in the cache.
public virtual ValueGenerator GetOrAdd(IProperty property, ITypeBase typeBase, Func<IProperty, ITypeBase, ValueGenerator> factory)
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
factory
Func<IProperty, ITypeBase, ValueGenerator>Factory to create a new value generator if one is not present in the cache.
Returns
- ValueGenerator
The existing or newly created value generator.