API reference — Persistence

Nuvora.Nexus.Relay.Persistence

Core persistence abstractions and interfaces for Nuvora Nexus Relay

dotnet add package Nuvora.Nexus.Relay.Persistence

Nuvora.Nexus.Relay.Persistence

IRepository<TEntity, TId>

public interface IRepository<TEntity, TId> where TEntity : Entity<TId> where TId : notnull

Generic repository interface for entities

Methods

Task AddAsync(TEntity entity, CancellationToken cancellationToken = default(CancellationToken))

Add entity

Task AddRangeAsync(IEnumerable<TEntity> entities, CancellationToken cancellationToken = default(CancellationToken))

Add multiple entities

Task RemoveAsync(TEntity entity, CancellationToken cancellationToken = default(CancellationToken))

Remove entity

Task RemoveAsync(TId id, CancellationToken cancellationToken = default(CancellationToken))

Remove entity by ID

Task RemoveRangeAsync(IEnumerable<TEntity> entities, CancellationToken cancellationToken = default(CancellationToken))

Remove multiple entities

Task RemoveWhereAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default(CancellationToken))

Remove entities by predicate

Task UpdateAsync(TEntity entity, CancellationToken cancellationToken = default(CancellationToken))

Update entity

Task UpdateRangeAsync(IEnumerable<TEntity> entities, CancellationToken cancellationToken = default(CancellationToken))

Update multiple entities

Task<IEnumerable<TEntity>> GetAllAsync(CancellationToken cancellationToken = default(CancellationToken))

Get all entities

Task<IEnumerable<TEntity>> GetWhereAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default(CancellationToken))

Get entities by predicate

Task<TEntity?> GetByIdAsync(TId id, CancellationToken cancellationToken = default(CancellationToken))

Get entity by ID

Task<bool> ExistsAsync(TId id, CancellationToken cancellationToken = default(CancellationToken))

Check if entity exists by ID

Task<int> CountAsync(CancellationToken cancellationToken = default(CancellationToken))

Count entities

Task<int> CountAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default(CancellationToken))

Count entities by predicate

IRepositoryFactory

public interface IRepositoryFactory

Factory interface for creating repositories

Methods

IRepository<TEntity, TId> CreateRepository<TEntity, TId>()

Create a repository for the specified entity type