using Microsoft.EntityFrameworkCore;
namespace StellaOps.Provcache.Postgres;
public sealed partial class PostgresProvcacheRepository
{
///
public async Task GetAsync(string veriKey, CancellationToken cancellationToken = default)
{
var entity = await _context.ProvcacheItems
.AsNoTracking()
.FirstOrDefaultAsync(e => e.VeriKey == veriKey, cancellationToken)
.ConfigureAwait(false);
return entity is null ? null : MapToEntry(entity);
}
///
public async Task> GetManyAsync(
IEnumerable veriKeys,
CancellationToken cancellationToken = default)
{
var keyList = veriKeys.ToList();
if (keyList.Count == 0)
return new Dictionary();
var entities = await _context.ProvcacheItems
.AsNoTracking()
.Where(e => keyList.Contains(e.VeriKey))
.ToListAsync(cancellationToken)
.ConfigureAwait(false);
return entities.ToDictionary(e => e.VeriKey, MapToEntry);
}
}