Interface IAnnotatable
- Namespace
- Microsoft.EntityFrameworkCore.Infrastructure
- Assembly
- Microsoft.EntityFrameworkCore.dll
A class that exposes build-time and run-time annotations. Annotations allow for arbitrary metadata to be stored on an object.
This interface is typically used by database providers (and other extensions). It is generally not used in application code.
public interface IAnnotatable : IReadOnlyAnnotatable
- Inherited Members
Remarks
See Implementation of database providers and extensions for more information and examples.
Methods
AddRuntimeAnnotation(string, object?)
Adds a runtime annotation to this object. Throws if an annotation with the specified name already exists.
IAnnotation AddRuntimeAnnotation(string name, object? value)
Parameters
name
stringThe name of the annotation to be added.
value
objectThe value to be stored in the annotation.
Returns
- IAnnotation
The newly added annotation.
FindRuntimeAnnotation(string)
Gets the runtime annotation with the given name, returning null if it does not exist.
IAnnotation? FindRuntimeAnnotation(string name)
Parameters
name
stringThe name of the annotation to find.
Returns
- IAnnotation
The existing runtime annotation if an annotation with the specified name already exists. Otherwise, null.
FindRuntimeAnnotationValue(string)
Gets the value of the runtime annotation with the given name, returning null if it does not exist.
object? FindRuntimeAnnotationValue(string name)
Parameters
name
stringThe name of the annotation to find.
Returns
- object
The value of the existing runtime annotation if an annotation with the specified name already exists. Otherwise, null.
GetOrAddRuntimeAnnotationValue<TValue, TArg>(string, Func<TArg?, TValue>, TArg?)
Gets the value of the runtime annotation with the given name, adding it if one does not exist.
TValue GetOrAddRuntimeAnnotationValue<TValue, TArg>(string name, Func<TArg?, TValue> valueFactory, TArg? factoryArgument)
Parameters
name
stringThe name of the annotation.
valueFactory
Func<TArg, TValue>The factory used to create the value if the annotation doesn't exist.
factoryArgument
TArgAn argument for the factory method.
Returns
- TValue
The value of the existing runtime annotation if an annotation with the specified name already exists. Otherwise a newly created value.
Type Parameters
TValue
TArg
GetRuntimeAnnotations()
Gets all the runtime annotations on the current object.
IEnumerable<IAnnotation> GetRuntimeAnnotations()
Returns
RemoveRuntimeAnnotation(string)
Removes the given runtime annotation from this object.
IAnnotation? RemoveRuntimeAnnotation(string name)
Parameters
name
stringThe name of the annotation to remove.
Returns
- IAnnotation
The annotation that was removed.
SetRuntimeAnnotation(string, object?)
Sets the runtime annotation stored under the given key. Overwrites the existing annotation if an annotation with the specified name already exists.
IAnnotation SetRuntimeAnnotation(string name, object? value)
Parameters
name
stringThe name of the annotation to be added.
value
objectThe value to be stored in the annotation.
Returns
- IAnnotation
The newly added annotation.