Class CharacterArchetypeService
Service for managing character archetypes in the database. Provides async operations for CRUD operations on character archetype data. Implements execution strategies for automatic retry on transient database failures. Returns DatabaseResult for consistent, safe error handling.
public sealed class CharacterArchetypeService : BaseService<CharacterArchetypeEntity>, ICharacterArchetypeService, IPersistManyAction<CharacterArchetypeData>, IDeleteByKeyVersionedAction<long>, IFetchCollectionByKeyAction<long, CharacterArchetypeData>
- Inheritance
-
CharacterArchetypeService
- Implements
- Inherited Members
Constructors
CharacterArchetypeService(INpgsqlDbContextFactory)
Initializes a new instance of the CharacterArchetypeService class.
public CharacterArchetypeService(INpgsqlDbContextFactory dbContextFactory)
Parameters
dbContextFactoryINpgsqlDbContextFactoryFactory for creating database contexts.
Exceptions
- ArgumentNullException
Thrown when dbContextFactory is null.
Methods
DeleteAsync(long, long, CancellationToken)
Deletes the entity identified by the given key if incomingVersion is newer.
public Task<DatabaseResult> DeleteAsync(long characterId, long incomingVersion, CancellationToken cancellationToken = default)
Parameters
characterIdlongincomingVersionlongThe authoritative, monotonic version for this delete operation.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
FetchAsync(long, CancellationToken)
Fetches a collection of items for the given key.
public Task<DatabaseResult<IReadOnlyList<CharacterArchetypeData>>> FetchAsync(long characterId, CancellationToken cancellationToken = default)
Parameters
characterIdlongcancellationTokenCancellationTokenToken to cancel the operation.
Returns
PersistAsync(IEnumerable<CharacterArchetypeData>, CancellationToken)
Persists the provided items.
public Task<DatabaseResult<BulkWriteResult>> PersistAsync(IEnumerable<CharacterArchetypeData> archetypes, CancellationToken cancellationToken = default)
Parameters
archetypesIEnumerable<CharacterArchetypeData>cancellationTokenCancellationTokenToken to cancel the operation.
Returns
- Task<DatabaseResult<BulkWriteResult>>
What the write actually did, or a failure.
Remarks
A successful result does not mean every supplied row was written. Batched writes are version-gated and the service filters what it cannot act on, so the outcome carries counts rather than a bare boolean — see BulkWriteResult, which explains which discrepancies a caller should care about and which are routine.