Table of Contents

Interface IClrCollectionAccessor

Namespace
Microsoft.EntityFrameworkCore.Metadata
Assembly
Microsoft.EntityFrameworkCore.dll

Represents operations backed by compiled delegates that allow manipulation of collections on navigation properties.

This type is typically used by database providers (and other extensions). It is generally not used in application code.

public interface IClrCollectionAccessor

Remarks

See Implementation of database providers and extensions for more information and examples.

Properties

CollectionType

The collection type.

Type CollectionType { get; }

Property Value

Type

Methods

Add(object, object, bool)

Adds a value to the navigation property collection, unless it is already contained in the collection.

bool Add(object entity, object value, bool forMaterialization)

Parameters

entity object

The entity instance.

value object

The value to add.

forMaterialization bool

If true, then the value is being added as part of query materialization.

Returns

bool

true if a value was added; false if it was already in the collection.

AddStandalone(object, object)

Adds a value to the passed collection, unless it is already contained in the collection.

bool AddStandalone(object collection, object value)

Parameters

collection object

The collection.

value object

The value to add.

Returns

bool

true if a value was added; false if it was already in the collection.

Contains(object, object)

Checks whether the value is contained in the collection.

bool Contains(object entity, object value)

Parameters

entity object

The entity instance.

value object

The value to check.

Returns

bool

true if the value is contained in the collection; false otherwise.

ContainsStandalone(object, object)

Checks whether the value is contained in the passed collection.

bool ContainsStandalone(object collection, object value)

Parameters

collection object

The collection.

value object

The value to check.

Returns

bool

true if the value is contained in the collection; false otherwise.

Create()

Creates a new collection instance of the appropriate type for the navigation property.

object Create()

Returns

object

The collection instance.

GetOrCreate(object, bool)

Either returns the existing collection instance set on the navigation property, or if none exists, then creates a new instance, sets it, and returns it.

object GetOrCreate(object entity, bool forMaterialization)

Parameters

entity object

The entity instance.

forMaterialization bool

If true, then this is happening as part of query materialization; false otherwise.

Returns

object

The existing or new collection.

Remove(object, object)

Removes a value from the collection.

bool Remove(object entity, object value)

Parameters

entity object

The entity instance.

value object

The value to check.

Returns

bool

true if the value was contained in the collection; false otherwise.

RemoveStandalone(object?, object)

Removes a value from the passed collection.

bool RemoveStandalone(object? collection, object value)

Parameters

collection object

The collection.

value object

The value to check.

Returns

bool

true if the value was contained in the collection; false otherwise.