Show / Hide Table of Contents

Interface IRepository<TKey, TEntity>

Base interface for general entity repositories.

Namespace: Ease.Repository
Assembly: Ease.Repository.dll
Syntax
public interface IRepository<in TKey, TEntity>
    where TEntity : TKey, new()
Type Parameters
Name Description
TKey
TEntity

Methods

| Improve this Doc View Source

Add(TEntity)

Adds the entity to the repository. NOTE: Caller should proceed with the returned entity rather than the passed entity to guarantee proper unit of work tracking to be managed (i.e. the returned entity is not guaranteed to be reference equal to the passed entity).

Declaration
TEntity Add(TEntity entity)
Parameters
Type Name Description
TEntity entity

The entity to create or update.

Returns
Type Description
TEntity

The resultant repository-persistent entity. CAUTION: Do not attempt to serialize returned repository entities. They are not guaranteed to be TEntity alone. They are more likely to be a dynamic proxy class inheriting from TEntity and extending it with additional properties you wouldn't want serialized. For serialization, you should map the entity to a suitably controlled DTO / view model, etc..

| Improve this Doc View Source

Delete(TKey)

Deletes an entity by its key. If the entity is already deleted, this does not generate an exception.

Declaration
void Delete(TKey key)
Parameters
Type Name Description
TKey key

The key (may be compound) to use to find the entity to delete.

| Improve this Doc View Source

Get(TKey)

Get an entity by its key.

Declaration
TEntity Get(TKey key)
Parameters
Type Name Description
TKey key

The key (may be compound) to use to look up the entity.

Returns
Type Description
TEntity

The matching entity, or null if not found. CAUTION: Do not attempt to serialize returned repository entities. They are not guaranteed to be TEntity alone. They are more likely to be a dynamic proxy class inheriting from TEntity and extending it with additional properties you wouldn't want serialized. For serialization, you should map the entity to a suitably controlled DTO / view model, etc..

Extension Methods

ChangeTrackingExtensions.CurrentState<T>(T)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX