Table of Contents

Interface IRepository<TEntity>

Namespace
GroupeIsa.Neos.Domain.Persistence
Assembly
GroupeIsa.Neos.Domain.Abstractions.dll

Represents a repository.

public interface IRepository<TEntity> : IRepository where TEntity : BusinessEntity

Type Parameters

TEntity

Type of objects in the repository.

Inherited Members

Methods

Add(TEntity)

Adds an object.

void Add(TEntity entity)

Parameters

entity TEntity

Added object.

AddNew()

Adds a new object.

TEntity AddNew()

Returns

TEntity

Added object.

Find(params object[])

Finds an entity with the given primary key values. If an entity with the given primary key values is being tracked by the context, then it is returned immediately without making a request to the storage. Otherwise, a query is made to the storage for an entity with the given primary key values and this entity, if found, is attached to the context and returned. If no entity is found, then null is returned.

TEntity? Find(params object[] keyValues)

Parameters

keyValues object[]

Key values.

Returns

TEntity

The entity found, or null.

FindAsync(params object[])

Finds an entity with the given primary key values. If an entity with the given primary key values is being tracked by the context, then it is returned immediately without making a request to the storage. Otherwise, a query is made to the storage for an entity with the given primary key values and this entity, if found, is attached to the context and returned. If no entity is found, then null is returned.

Task<TEntity?> FindAsync(params object[] keyValues)

Parameters

keyValues object[]

Key values.

Returns

Task<TEntity>

The entity found, or null.

FindAsync(object[], CancellationToken)

Finds an entity with the given primary key values. If an entity with the given primary key values is being tracked by the context, then it is returned immediately without making a request to the storage. Otherwise, a query is made to the storage for an entity with the given primary key values and this entity, if found, is attached to the context and returned. If no entity is found, then null is returned.

Task<TEntity?> FindAsync(object[] keyValues, CancellationToken cancellationToken)

Parameters

keyValues object[]

Key values.

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task<TEntity>

The entity found, or null.

Get(params object[])

Gets an entity with the given primary key values. If an entity with the given primary key values is being tracked by the context, then it is returned immediately without making a request to the storage. Otherwise, a query is made to the storage for an entity with the given primary key values and this entity, if found, is attached to the context and returned.

TEntity Get(params object[] keyValues)

Parameters

keyValues object[]

Key values.

Returns

TEntity

The entity found.

Exceptions

InvalidOperationException

There is no entity with the given primary key values.

GetAll()

Retrieves all entities from the data source.

IEnumerable<TEntity> GetAll()

Returns

IEnumerable<TEntity>

An enumerable collection of all entities in the data source.

GetAll(bool?)

Retrieves all entities from the data source.

IEnumerable<TEntity> GetAll(bool? asTracking)

Parameters

asTracking bool?

Specifies whether the returned entities should be tracked for changes. If true, entities are tracked; if false, entities are not tracked. If null, the default tracking behavior is used.

Returns

IEnumerable<TEntity>

An enumerable collection of all entities in the data source.

GetAllAsync()

Retrieves all entities of from the data source.

IAsyncEnumerable<TEntity> GetAllAsync()

Returns

IAsyncEnumerable<TEntity>

An enumerable collection of all entities in the data source.

GetAllAsync(bool?)

Retrieves all entities from the data source.

IAsyncEnumerable<TEntity> GetAllAsync(bool? asTracking)

Parameters

asTracking bool?

Specifies whether the returned entities should be tracked for changes. If true, entities are tracked; if false, entities are not tracked. If null, the default tracking behavior is used.

Returns

IAsyncEnumerable<TEntity>

An enumerable collection of all entities in the data source.

GetAsync(params object[])

Gets an entity with the given primary key values. If an entity with the given primary key values is being tracked by the context, then it is returned immediately without making a request to the storage. Otherwise, a query is made to the storage for an entity with the given primary key values and this entity, if found, is attached to the context and returned.

Task<TEntity> GetAsync(params object[] keyValues)

Parameters

keyValues object[]

Key values.

Returns

Task<TEntity>

The entity found.

Exceptions

InvalidOperationException

There is no entity with the given primary key values.

GetAsync(object[], CancellationToken)

Gets an entity with the given primary key values. If an entity with the given primary key values is being tracked by the context, then it is returned immediately without making a request to the storage. Otherwise, a query is made to the storage for an entity with the given primary key values and this entity, if found, is attached to the context and returned.

Task<TEntity> GetAsync(object[] keyValues, CancellationToken cancellationToken)

Parameters

keyValues object[]

Key values.

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task<TEntity>

The entity found.

Exceptions

InvalidOperationException

There is no entity with the given primary key values.

GetKeyValues(TEntity)

Gets the key of an entity.

object[] GetKeyValues(TEntity entity)

Parameters

entity TEntity

Entity.

Returns

object[]

Key.

GetOriginal(TEntity)

Gets the original state of an object.

TEntity GetOriginal(TEntity updatedEntity)

Parameters

updatedEntity TEntity

Modified object.

Returns

TEntity

Item in its original state.

Remarks

With a database persistence, navigation properties are functionals and returns the original values (if necessary, lazy loaded is triggered).

GetQuery()

Gets a query.

IQueryable<TEntity> GetQuery()

Returns

IQueryable<TEntity>

Query.

GetState(TEntity)

Gets the state of an entity.

BusinessEntityState GetState(TEntity entity)

Parameters

entity TEntity

The entity.

Returns

BusinessEntityState

The state of the entity.

New()

Creates a new entity instance.

TEntity New()

Returns

TEntity

The created entity instance.

ReloadAsync(TEntity, CancellationToken)

Reloads an entity from the database, overwriting any changes made to the entity.

Task ReloadAsync(TEntity entity, CancellationToken cancellationToken = default)

Parameters

entity TEntity

The entity.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

A Task representing the asynchronous operation.

Remove(TEntity)

Removes an object.

void Remove(TEntity entity)

Parameters

entity TEntity

Removed object.

SetOriginalValue(TEntity, string, object?)

Sets the original values for concurrency access.

void SetOriginalValue(TEntity entity, string propertyName, object? originalValue)

Parameters

entity TEntity

The entity.

propertyName string

The property name.

originalValue object

The original value.