Class AnnotatableBase
- Namespace
- LinqToDB.Internal.Infrastructure
- Assembly
- linq2db.dll
Base class for types that support reading and writing annotations.
This type is typically used by linq2db providers and extensions. It is generally not used in application code.
public class AnnotatableBase : IReadOnlyAnnotatable
- Inheritance
-
objectAnnotatableBase
- Implements
- Derived
- Extension Methods
Properties
IsReadOnly
Indicates whether the current object is read-only.
public virtual bool IsReadOnly { get; }
Property Value
Remarks
Annotations cannot be changed when the object is read-only.
this[string]
Gets the value annotation with the given name, returning null if it does not exist.
public virtual object? this[string name] { get; set; }
Parameters
namestringThe key of the annotation to find.
Property Value
- object
The value of the existing annotation if an annotation with the specified name already exists. Otherwise, null.
Methods
AddAnnotation(string, Annotation)
Adds an annotation to this object. Throws if an annotation with the specified name already exists.
protected virtual Annotation AddAnnotation(string name, Annotation annotation)
Parameters
namestringThe key of the annotation to be added.
annotationAnnotationThe annotation to be added.
Returns
- Annotation
The added annotation.
AddAnnotation(string, object?)
Adds an annotation to this object. Throws if an annotation with the specified name already exists.
public virtual Annotation AddAnnotation(string name, object? value)
Parameters
namestringThe key of the annotation to be added.
valueobjectThe value to be stored in the annotation.
Returns
- Annotation
The newly added annotation.
AddAnnotations(IEnumerable<IAnnotation>)
Adds annotations to this object.
public virtual void AddAnnotations(IEnumerable<IAnnotation> annotations)
Parameters
annotationsIEnumerable<IAnnotation>The annotations to be added.
AddAnnotations(IReadOnlyDictionary<string, object?>)
Adds annotations to this object.
public virtual void AddAnnotations(IReadOnlyDictionary<string, object?> annotations)
Parameters
annotationsIReadOnlyDictionary<string, object>The annotations to be added.
CreateAnnotation(string, object?)
Creates a new annotation.
protected virtual Annotation CreateAnnotation(string name, object? value)
Parameters
namestringThe key of the annotation.
valueobjectThe value to be stored in the annotation.
Returns
- Annotation
The newly created annotation.
EnsureMutable()
Throws if the model is read-only.
protected virtual void EnsureMutable()
FindAnnotation(string)
Gets the annotation with the given name, returning null if it does not exist.
public virtual Annotation? FindAnnotation(string name)
Parameters
namestringThe key of the annotation to find.
Returns
- Annotation
The existing annotation if an annotation with the specified name already exists. Otherwise, null.
GetAnnotation(string)
Gets the annotation with the given name, throwing if it does not exist.
public virtual Annotation GetAnnotation(string annotationName)
Parameters
annotationNamestringThe key of the annotation to find.
Returns
- Annotation
The annotation with the specified name.
GetAnnotations()
Gets all annotations on the current object.
public virtual IEnumerable<Annotation> GetAnnotations()
Returns
OnAnnotationSet(string, Annotation?, Annotation?)
Called when an annotation was set or removed.
protected virtual Annotation? OnAnnotationSet(string name, Annotation? annotation, Annotation? oldAnnotation)
Parameters
namestringThe key of the set annotation.
annotationAnnotationThe annotation set.
oldAnnotationAnnotationThe old annotation.
Returns
- Annotation
The annotation that was set.
RemoveAnnotation(string)
Removes the given annotation from this object.
public virtual Annotation? RemoveAnnotation(string name)
Parameters
namestringThe annotation to remove.
Returns
- Annotation
The annotation that was removed.
SetAnnotation(string, Annotation, Annotation?)
Sets the annotation stored under the given key. Overwrites the existing annotation if an annotation with the specified name already exists.
protected virtual Annotation? SetAnnotation(string name, Annotation annotation, Annotation? oldAnnotation)
Parameters
namestringThe key of the annotation to be added.
annotationAnnotationThe annotation to be set.
oldAnnotationAnnotationThe annotation being replaced.
Returns
- Annotation
The annotation that was set.
SetAnnotation(string, object?)
Sets the annotation stored under the given key. Overwrites the existing annotation if an annotation with the specified name already exists.
public virtual void SetAnnotation(string name, object? value)
Parameters
namestringThe key of the annotation to be added.
valueobjectThe value to be stored in the annotation.