IClrCollectionAccessor.GetOrCreate(Object, Boolean) Method

Definition

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.

C#
public object GetOrCreate (object entity, bool forMaterialization);

Parameters

entity
Object

The entity instance.

forMaterialization
Boolean

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

Returns

The existing or new collection.

Applies to

Product Versions
Entity Framework Core 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0