checkpoint
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using Dapper;
|
||||
using Shogi.Api.Repositories.Dto;
|
||||
using Shogi.Api.Repositories.Dto.SessionState;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Shogi.Api.Repositories;
|
||||
|
||||
@@ -21,4 +23,27 @@ public class QueryRepository(IConfiguration configuration)
|
||||
|
||||
return await results.ReadAsync<SessionDto>();
|
||||
}
|
||||
|
||||
public async Task<List<SessionStateDocument>> ReadSessionSnapshots(string sessionId)
|
||||
{
|
||||
using var connection = new SqlConnection(this.connectionString);
|
||||
var command = connection.CreateCommand();
|
||||
command.CommandText = "session.ReadStatesBySession";
|
||||
command.CommandType = CommandType.StoredProcedure;
|
||||
command.Parameters.AddWithValue("SessionId", sessionId);
|
||||
|
||||
await using var reader = await command.ExecuteReaderAsync();
|
||||
var documents = new List<SessionStateDocument>(20);
|
||||
while (await reader.ReadAsync())
|
||||
{
|
||||
var json = reader.GetString("Document");
|
||||
var document = JsonSerializer.Deserialize<SessionStateDocument>(json);
|
||||
if (document != null)
|
||||
{
|
||||
documents.Add(document);
|
||||
}
|
||||
}
|
||||
|
||||
return documents;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user