Table of Contents

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
object
AnnotatableBase
Implements
Derived
Extension Methods

Properties

IsReadOnly

Indicates whether the current object is read-only.

public virtual bool IsReadOnly { get; }

Property Value

bool

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

name string

The 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

name string

The key of the annotation to be added.

annotation Annotation

The 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

name string

The key of the annotation to be added.

value object

The 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

annotations IEnumerable<IAnnotation>

The annotations to be added.

AddAnnotations(IReadOnlyDictionary<string, object?>)

Adds annotations to this object.

public virtual void AddAnnotations(IReadOnlyDictionary<string, object?> annotations)

Parameters

annotations IReadOnlyDictionary<string, object>

The annotations to be added.

CreateAnnotation(string, object?)

Creates a new annotation.

protected virtual Annotation CreateAnnotation(string name, object? value)

Parameters

name string

The key of the annotation.

value object

The 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

name string

The 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

annotationName string

The 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

IEnumerable<Annotation>

OnAnnotationSet(string, Annotation?, Annotation?)

Called when an annotation was set or removed.

protected virtual Annotation? OnAnnotationSet(string name, Annotation? annotation, Annotation? oldAnnotation)

Parameters

name string

The key of the set annotation.

annotation Annotation

The annotation set.

oldAnnotation Annotation

The 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

name string

The 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

name string

The key of the annotation to be added.

annotation Annotation

The annotation to be set.

oldAnnotation Annotation

The 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

name string

The key of the annotation to be added.

value object

The value to be stored in the annotation.