31 lines
1.0 KiB
C#
31 lines
1.0 KiB
C#
using System.Data;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Server.Data;
|
|
|
|
/// <summary>
|
|
/// Central entry for DB access: resilient connections, optional transactions, and utility helpers.
|
|
/// Works great for Dapper or ADO.NET; EF Core can reuse the same connection string.
|
|
/// </summary>
|
|
public interface IDatabaseManager
|
|
{
|
|
Task<T> ExecuteAsync<T>(
|
|
Func<IDbConnection, Task<T>> operation,
|
|
CancellationToken cancellationToken = default);
|
|
|
|
Task ExecuteAsync(
|
|
Func<IDbConnection, Task> operation,
|
|
CancellationToken cancellationToken = default);
|
|
|
|
Task<T> WithTransactionAsync<T>(
|
|
Func<IDbConnection, IDbTransaction, Task<T>> operation,
|
|
IsolationLevel isolationLevel = IsolationLevel.ReadCommitted,
|
|
CancellationToken cancellationToken = default);
|
|
|
|
Task WithTransactionAsync(
|
|
Func<IDbConnection, IDbTransaction, Task> operation,
|
|
IsolationLevel isolationLevel = IsolationLevel.ReadCommitted,
|
|
CancellationToken cancellationToken = default);
|
|
}
|