mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 10:42:08 +00:00
Update repository, seed and service layers
This commit is contained in:
24
DataAccessLayer/Repositories/Repository.cs
Normal file
24
DataAccessLayer/Repositories/Repository.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user