Table of Contents

Class EntityCollectionProperty<T>

Namespace
The.Relationships
Assembly
Instagile.dll

A one-to-many-T foreign key

public sealed class EntityCollectionProperty<T> : EntityCollectionProperty, IEntitySet<T>, IFrozenQuery<T>, IEntityQuery<T>, IEntityQuery, IDisposable, ILazy, ILoadedSet<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable, INotifyCollectionChanged, IProperty, IOwned, IHasChanges, IVisitor<IEntityQuery<T>> where T : IEntity<T>

Type Parameters

T
Inheritance
EntityCollectionProperty<T>
Implements
Inherited Members
Extension Methods

Constructors

EntityCollectionProperty(RelationshipInfo, EntityKernel)

public EntityCollectionProperty(RelationshipInfo metadata, EntityKernel parent)

Parameters

metadata RelationshipInfo
parent EntityKernel

Properties

CacheState

Whether data was loaded from the entity cache and, if so, whether it's up to date.

public ResultState CacheState { get; }

Property Value

ResultState

ElementType

Gets the type of the element(s) that are returned when the expression tree associated with this instance of IEntityQuery is executed.

public Type ElementType { get; }

Property Value

Type

Expression

Gets the expression tree that is associated with the instance of IEntityQuery.

public Expression Expression { get; }

Property Value

Expression

OriginalValue

public IEntityQuery<T> OriginalValue { get; }

Property Value

IEntityQuery<T>

Provider

Gets the query provider that is associated with this data source.

public IEntityQueryProvider Provider { get; }

Property Value

IEntityQueryProvider

Methods

Add(IEntity)

public override void Add(IEntity item)

Parameters

item IEntity

Add(T)

public void Add(T item)

Parameters

item T

AddAsync(IEntity, CancellationToken?)

public Task AddAsync(IEntity item, CancellationToken? cancellationToken = null)

Parameters

item IEntity
cancellationToken CancellationToken?

Returns

Task

AddAsync(T, CancellationToken?)

public Task AddAsync(T item, CancellationToken? cancellationToken = null)

Parameters

item T
cancellationToken CancellationToken?

Returns

Task

AddRange(IEnumerable<IEntity>)

public override void AddRange(IEnumerable<IEntity> items)

Parameters

items IEnumerable<IEntity>

AddRange(IEnumerable<T>)

public void AddRange(IEnumerable<T> items)

Parameters

items IEnumerable<T>

AddRangeAsync(IEnumerable<T>, CancellationToken?)

public Task AddRangeAsync(IEnumerable<T> items, CancellationToken? cancellationToken = null)

Parameters

items IEnumerable<T>
cancellationToken CancellationToken?

Returns

Task

AsLoaded()

Assert that the set is loaded and treat it as iterable.

public ILoadedSet<T> AsLoaded()

Returns

ILoadedSet<T>

Exceptions

InvalidOperationException

Thrown if the set is partially or entirely unloaded.

AsUnloaded()

Assert that the set is unloaded and treat it as a datastore query.

public IEntityQuery<T> AsUnloaded()

Returns

IEntityQuery<T>

Remarks

An empty set is always considered loaded. Calling this method on an empty set will cause an exception to be thrown.

Exceptions

InvalidOperationException

Thrown if the set is partially or entirely loaded.

Clear()

public override void Clear()

ClearAsync(CancellationToken?)

public override Task ClearAsync(CancellationToken? cancellationToken = null)

Parameters

cancellationToken CancellationToken?

Returns

Task

Clone(IEntityContext?)

public EntityCollectionProperty<T> Clone(IEntityContext? context = null)

Parameters

context IEntityContext

Returns

EntityCollectionProperty<T>

Contains(IEntity?)

protected override bool Contains(IEntity? item)

Parameters

item IEntity

Returns

bool

Contains(T?)

public bool Contains(T? item)

Parameters

item T

Returns

bool

ContainsAsync(T?, CancellationToken?)

public Task<bool> ContainsAsync(T? item, CancellationToken? cancellationToken = null)

Parameters

item T
cancellationToken CancellationToken?

Returns

Task<bool>

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

EagerLoad(IEnumerable<T>)

public void EagerLoad(IEnumerable<T> entities)

Parameters

entities IEnumerable<T>

EagerLoad(params T[])

public void EagerLoad(params T[] entities)

Parameters

entities T[]

GetEnumerator()

public IEnumerator<T> GetEnumerator()

Returns

IEnumerator<T>

GetRelatedEntities()

protected override IEnumerable<IEntity> GetRelatedEntities()

Returns

IEnumerable<IEntity>

GetRelatedEntitiesAsync(RelationshipPath[], CancellationToken?)

protected override Task<IEnumerable<IEntity>> GetRelatedEntitiesAsync(RelationshipPath[] includeRelationships, CancellationToken? cancellationToken)

Parameters

includeRelationships RelationshipPath[]
cancellationToken CancellationToken?

Returns

Task<IEnumerable<IEntity>>

GetRelatedEntitiesCachedAsync(RelationshipPath[], RequestOptions, CancellationToken?)

protected override Task<IEnumerable<IEntity>> GetRelatedEntitiesCachedAsync(RelationshipPath[] includeRelationships, RequestOptions options, CancellationToken? cancellationToken)

Parameters

includeRelationships RelationshipPath[]
options RequestOptions
cancellationToken CancellationToken?

Returns

Task<IEnumerable<IEntity>>

IsInMemory()

Returns true if the frozen query is at least partially-loaded. In-memory queries should not be transformed into ReadOperations for batching.

public bool IsInMemory()

Returns

bool

LoadAsync(CancellationToken?)

Load the whole set into memory for iteration or modification, including related entities.

public Task<ILoadedSet<T>> LoadAsync(CancellationToken? cancellationToken = null)

Parameters

cancellationToken CancellationToken?

Cancellation token.

Returns

Task<ILoadedSet<T>>

The loaded set.

LoadAsync(RelationshipPath[], CancellationToken?)

Load the whole set into memory for iteration or modification.

public Task<ILoadedSet<T>> LoadAsync(RelationshipPath[] includeRelationships, CancellationToken? cancellationToken = null)

Parameters

includeRelationships RelationshipPath[]

Relationship paths to load along with the set. If the set is already loaded, just the paths will be loaded.

cancellationToken CancellationToken?

Cancellation token.

Returns

Task<ILoadedSet<T>>

The loaded set.

LoadCachedAsync(RequestOptions?, CancellationToken?)

Load the whole set into memory for iteration or modification, including related entities. Uses the entity cache if possible. If the result was stale, CollectionChanged will be raised after validation.

public Task<ILoadedSet<T>> LoadCachedAsync(RequestOptions? options = null, CancellationToken? cancellationToken = null)

Parameters

options RequestOptions

Request options (priority, freshness requirements).

cancellationToken CancellationToken?

Cancellation token.

Returns

Task<ILoadedSet<T>>

The loaded set.

Remarks

Check CacheState after calling to determine if a background refresh is in progress:

  • Fresh - Data is current, no refresh pending
  • Stale - Showing cached data, refresh in progress
  • Uncached - Data not from cache (for example, if already loaded)

If the collection is modified locally before the background refresh completes, the refresh will be silently skipped to preserve local changes.

Cache updates are marshalled to the calling thread's SynchronizationContext if available (e.g., WPF UI thread, Blazor component context).

LoadCachedAsync(RelationshipPath[], RequestOptions?, CancellationToken?)

Load the whole set into memory for iteration or modification. Uses the entity cache if possible. If the result was stale, CollectionChanged will be raised after validation.

public Task<ILoadedSet<T>> LoadCachedAsync(RelationshipPath[] includes, RequestOptions? options = null, CancellationToken? cancellationToken = null)

Parameters

includes RelationshipPath[]

Relationship paths to load along with the set. If the set is already loaded, uses GraphNavigation.LoadGraphAsync to load the paths.

options RequestOptions

Request options (priority, freshness requirements).

cancellationToken CancellationToken?

Cancellation token.

Returns

Task<ILoadedSet<T>>

The loaded set.

Remarks

Check CacheState after calling to determine if a background refresh is in progress:

  • Fresh - Data is current, no refresh pending
  • Stale - Showing cached data, refresh in progress
  • Uncached - Data not from cache (for example, if already loaded)

If the collection is modified locally before the background refresh completes, the refresh will be silently skipped to preserve local changes.

Cache updates are marshalled to the calling thread's SynchronizationContext if available (e.g., WPF UI thread, Blazor component context).

Remove(IEntity)

public override void Remove(IEntity item)

Parameters

item IEntity

Remove(T)

public void Remove(T item)

Parameters

item T

RemoveAsync(IEntity, CancellationToken?)

public Task RemoveAsync(IEntity item, CancellationToken? cancellationToken = null)

Parameters

item IEntity
cancellationToken CancellationToken?

Returns

Task

RemoveAsync(T, CancellationToken?)

public Task RemoveAsync(T item, CancellationToken? cancellationToken = null)

Parameters

item T
cancellationToken CancellationToken?

Returns

Task

RemoveRange(IEnumerable<IEntity>)

public override void RemoveRange(IEnumerable<IEntity> items)

Parameters

items IEnumerable<IEntity>

RemoveRange(IEnumerable<T>)

public void RemoveRange(IEnumerable<T> items)

Parameters

items IEnumerable<T>

RemoveRangeAsync(IEnumerable<T>, CancellationToken?)

public Task RemoveRangeAsync(IEnumerable<T> items, CancellationToken? cancellationToken = null)

Parameters

items IEnumerable<T>
cancellationToken CancellationToken?

Returns

Task

ReplaceAll(IEnumerable<T>)

public void ReplaceAll(IEnumerable<T> entities)

Parameters

entities IEnumerable<T>

ReplaceAll(IEntitySet<T>)

public void ReplaceAll(IEntitySet<T> entities)

Parameters

entities IEntitySet<T>

ReplaceAllAsync(IEnumerable<T>, CancellationToken?)

public Task ReplaceAllAsync(IEnumerable<T> entities, CancellationToken? cancellationToken = null)

Parameters

entities IEnumerable<T>
cancellationToken CancellationToken?

Returns

Task