mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 10:42:08 +00:00
25 lines
775 B
C#
25 lines
775 B
C#
using DataAccessLayer.Sql;
|
|
using Microsoft.Data.SqlClient;
|
|
|
|
namespace DataAccessLayer.Repositories
|
|
{
|
|
public abstract class Repository<T>(ISqlConnectionFactory connectionFactory)
|
|
where T : class
|
|
{
|
|
protected async Task<SqlConnection> CreateConnection()
|
|
{
|
|
var connection = connectionFactory.CreateConnection();
|
|
await connection.OpenAsync();
|
|
return connection;
|
|
}
|
|
|
|
public abstract Task Add(T entity);
|
|
public abstract Task<IEnumerable<T>> GetAll(int? limit, int? offset);
|
|
public abstract Task<T?> GetById(Guid id);
|
|
public abstract Task Update(T entity);
|
|
public abstract Task Delete(Guid id);
|
|
|
|
protected abstract T MapToEntity(SqlDataReader reader);
|
|
}
|
|
}
|