Table of Contents

Interface IRepositoryCollection<TEntity, TKey>

Namespace
Tharga.MongoDB
Assembly
Tharga.MongoDB.dll
public interface IRepositoryCollection<TEntity, TKey> : IReadOnlyRepositoryCollection<TEntity, TKey>, IRepositoryCollection, IReadOnlyRepositoryCollection where TEntity : EntityBase<TKey>

Type Parameters

TEntity
TKey
Inherited Members

Methods

AddAsync(TEntity, IClientSessionHandle)

Task AddAsync(TEntity entity, IClientSessionHandle session = null)

Parameters

entity TEntity
session IClientSessionHandle

Returns

Task

AddManyAsync(IEnumerable<TEntity>, IClientSessionHandle)

Task AddManyAsync(IEnumerable<TEntity> entities, IClientSessionHandle session = null)

Parameters

entities IEnumerable<TEntity>
session IClientSessionHandle

Returns

Task

DeleteOneAsync(TKey, IClientSessionHandle)

Task<TEntity> DeleteOneAsync(TKey id, IClientSessionHandle session = null)

Parameters

id TKey
session IClientSessionHandle

Returns

Task<TEntity>

ExecuteAsync<T>(Func<IMongoCollection<TEntity>, CancellationToken, Task<T>>, Operation, CancellationToken)

Task<T> ExecuteAsync<T>(Func<IMongoCollection<TEntity>, CancellationToken, Task<T>> execute, Operation operation, CancellationToken cancellationToken)

Parameters

execute Func<IMongoCollection<TEntity>, CancellationToken, Task<T>>
operation Operation
cancellationToken CancellationToken

Returns

Task<T>

Type Parameters

T

ExecuteAsync<T>(Func<IMongoCollection<TEntity>, Task<T>>, Operation)

Task<T> ExecuteAsync<T>(Func<IMongoCollection<TEntity>, Task<T>> execute, Operation operation)

Parameters

execute Func<IMongoCollection<TEntity>, Task<T>>
operation Operation

Returns

Task<T>

Type Parameters

T

ExecuteManyAsync<T>(Func<IMongoCollection<TEntity>, CancellationToken, Task<IAsyncCursor<T>>>, CancellationToken)

IAsyncEnumerable<T> ExecuteManyAsync<T>(Func<IMongoCollection<TEntity>, CancellationToken, Task<IAsyncCursor<T>>> queryFactory, CancellationToken cancellationToken = default)

Parameters

queryFactory Func<IMongoCollection<TEntity>, CancellationToken, Task<IAsyncCursor<T>>>
cancellationToken CancellationToken

Returns

IAsyncEnumerable<T>

Type Parameters

T

GetPageAsync(int, PagePosition, Expression<Func<TEntity, bool>>, Expression<Func<TEntity, object>>, bool, CancellationToken)

Keyset (seek-based) pagination. Cost is O(log N) per page regardless of how deep the page sits — no skip penalty on deep pages or "jump to last." Single-column sort only; total count is intentionally not part of the result and should be obtained via CountAsync(predicate) separately.

Task<CursorPage<TEntity>> GetPageAsync(int pageSize, PagePosition position, Expression<Func<TEntity, bool>> predicate = null, Expression<Func<TEntity, object>> sortBy = null, bool ascending = true, CancellationToken cancellationToken = default)

Parameters

pageSize int
position PagePosition
predicate Expression<Func<TEntity, bool>>
sortBy Expression<Func<TEntity, object>>
ascending bool
cancellationToken CancellationToken

Returns

Task<CursorPage<TEntity>>

GetPageProjectionAsync<T>(int, PagePosition, Expression<Func<TEntity, T>>, Expression<Func<TEntity, bool>>, Expression<Func<TEntity, object>>, bool, CancellationToken)

Task<CursorPage<T>> GetPageProjectionAsync<T>(int pageSize, PagePosition position, Expression<Func<TEntity, T>> projection, Expression<Func<TEntity, bool>> predicate = null, Expression<Func<TEntity, object>> sortBy = null, bool ascending = true, CancellationToken cancellationToken = default)

Parameters

pageSize int
position PagePosition
projection Expression<Func<TEntity, T>>
predicate Expression<Func<TEntity, bool>>
sortBy Expression<Func<TEntity, object>>
ascending bool
cancellationToken CancellationToken

Returns

Task<CursorPage<T>>

Type Parameters

T

TryAddAsync(TEntity, IClientSessionHandle)

Task<bool> TryAddAsync(TEntity entity, IClientSessionHandle session = null)

Parameters

entity TEntity
session IClientSessionHandle

Returns

Task<bool>