29 lines
772 B
C#
29 lines
772 B
C#
using Dapper;
|
|
using Shogi.Api.Repositories.Dto;
|
|
using Shogi.Contracts.Types;
|
|
using System.Data.SqlClient;
|
|
|
|
namespace Shogi.Api.Repositories;
|
|
|
|
public class QueryRepository : IQueryRespository
|
|
{
|
|
private readonly string connectionString;
|
|
|
|
public QueryRepository(IConfiguration configuration)
|
|
{
|
|
connectionString = configuration.GetConnectionString("ShogiDatabase");
|
|
}
|
|
|
|
public async Task<IEnumerable<SessionMetadata>> ReadAllSessionsMetadata()
|
|
{
|
|
using var connection = new SqlConnection(connectionString);
|
|
return await connection.QueryAsync<SessionMetadata>(
|
|
"session.ReadAllSessionsMetadata",
|
|
commandType: System.Data.CommandType.StoredProcedure);
|
|
}
|
|
}
|
|
|
|
public interface IQueryRespository
|
|
{
|
|
Task<IEnumerable<SessionMetadata>> ReadAllSessionsMetadata();
|
|
} |