Table of Contents

Class AccountRepository

Namespace
Moongate.Persistence.Services.Persistence
Assembly
Moongate.Persistence.dll

Thread-safe account repository backed by the shared persistence state store.

public sealed class AccountRepository : IAccountRepository
Inheritance
AccountRepository
Implements
Inherited Members

Methods

AddAsync(UOAccountEntity, CancellationToken)

Adds a new account if the identifier and username are not already present.

public ValueTask<bool> AddAsync(UOAccountEntity account, CancellationToken cancellationToken = default)

Parameters

account UOAccountEntity
cancellationToken CancellationToken

Returns

ValueTask<bool>

CountAsync(CancellationToken)

Returns the current number of persisted accounts.

public ValueTask<int> CountAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

ValueTask<int>

ExistsAsync(Func<UOAccountEntity, bool>, CancellationToken)

Returns true when at least one account matches the predicate.

public ValueTask<bool> ExistsAsync(Func<UOAccountEntity, bool> predicate, CancellationToken cancellationToken = default)

Parameters

predicate Func<UOAccountEntity, bool>
cancellationToken CancellationToken

Returns

ValueTask<bool>

GetAllAsync(CancellationToken)

Returns all persisted accounts.

public ValueTask<IReadOnlyCollection<UOAccountEntity>> GetAllAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

ValueTask<IReadOnlyCollection<UOAccountEntity>>

GetByIdAsync(Serial, CancellationToken)

Gets an account by its serial identifier.

public ValueTask<UOAccountEntity?> GetByIdAsync(Serial id, CancellationToken cancellationToken = default)

Parameters

id Serial
cancellationToken CancellationToken

Returns

ValueTask<UOAccountEntity>

GetByUsernameAsync(string, CancellationToken)

Gets an account by username.

public ValueTask<UOAccountEntity?> GetByUsernameAsync(string username, CancellationToken cancellationToken = default)

Parameters

username string
cancellationToken CancellationToken

Returns

ValueTask<UOAccountEntity>

QueryAsync<TResult>(Func<UOAccountEntity, bool>, Func<UOAccountEntity, TResult>, CancellationToken)

Runs a projection query over account entities.

public ValueTask<IReadOnlyList<TResult>> QueryAsync<TResult>(Func<UOAccountEntity, bool> predicate, Func<UOAccountEntity, TResult> selector, CancellationToken cancellationToken = default)

Parameters

predicate Func<UOAccountEntity, bool>
selector Func<UOAccountEntity, TResult>
cancellationToken CancellationToken

Returns

ValueTask<IReadOnlyList<TResult>>

Type Parameters

TResult

RemoveAsync(Serial, CancellationToken)

Removes an account by its serial identifier.

public ValueTask<bool> RemoveAsync(Serial id, CancellationToken cancellationToken = default)

Parameters

id Serial
cancellationToken CancellationToken

Returns

ValueTask<bool>

UpsertAsync(UOAccountEntity, CancellationToken)

Inserts or updates an account.

public ValueTask UpsertAsync(UOAccountEntity account, CancellationToken cancellationToken = default)

Parameters

account UOAccountEntity
cancellationToken CancellationToken

Returns

ValueTask