Skip to content

Izayoi.Data.Repository.DbRepositoryBase

IzayoiJiichan edited this page Sep 7, 2024 · 5 revisions

DbRepositoryBase

Definition

Namespace Izayoi.Data.Repository
Assembly Izayoi.Data.Repository.dll

Represents a DB repository base.

public abstract class DbRepositoryBase<TData, TKey>

Type Parameters

TData

The map class.

TKey

The data type of the key column.

Inheritance

Object -> DbRepositoryBase<TData, TKey>

Constructors

Name Summary
DbRepositoryBase(IDbDataMapper dbDataMapper, QueryOption queryOption) Initializes a new instance of the DbRepositoryBase class with the specified dbDataMapper and queryOption.
DbRepositoryBase(IDbCommandAdapter dbCommandAdapter) Initializes a new instance of the DbRepositoryBase class with the specified dbCommandAdapter.

Methods

Name Returns Summary
GetCountAsync(DbConnection dbConnection, CancellationToken cancellationToken) Task<int> Gets the count of records.
FetchAsync(DbConnection dbConnection, TKey id, CancellationToken cancellationToken) Task<TData?> Gets the data for the specified ID.
FetchAsync(DbConnection dbConnection, IEnumerable<TKey> ids, CancellationToken cancellationToken) Task<List<TData>> Gets the data for the specified IDs.
FetchAllAsync(DbConnection dbConnection, CancellationToken cancellationToken) Task<List<TData>> Gets all the data.
InsertAsync(DbConnection dbConnection, TData data, CancellationToken cancellationToken) Task<int> Executes an INSERT query.
InsertReturnAsync(DbConnection dbConnection, TData data, CancellationToken cancellationToken) Task<int> Execute the INSERT query, get the inserted identity value, and set it in the data.
UpdateAsync(DbConnection dbConnection, TData data, CancellationToken cancellationToken) Task<int> Executes an UPDATE query.
DeleteAsync(DbConnection dbConnection, TKey id, CancellationToken cancellationToken) Task<int> Executes a DELETE query.
DeleteAsync(DbConnection dbConnection, TData data, CancellationToken cancellationToken) Task<int> Executes a DELETE query.
GetCommandTimeout(int queryType) int Get command timeout.
SetCommandTimeout(int queryType, int timeout) void Set command timeout.

Examples

Example.DbRepository

Remarks

This Base does not support transactions, so if you want to support transactions, create your own Base.

Applies to

Product Versions
.NET 8
Clone this wiki locally