Fix DbUpdateException in TradeRepository and Polymarket API 400 on max offset

This commit is contained in:
Richard
2026-07-07 12:23:37 +02:00
parent 1485c7cba9
commit 5ca50836a9
2 changed files with 16 additions and 3 deletions
@@ -69,7 +69,20 @@ public class TradeRepository : ITradeRepository
{
try { _db.Entry(t).State = EntityState.Detached; } catch { }
}
throw;
// Fallback to inserting one by one to avoid losing the entire batch due to a single duplicate
foreach (var t in trades)
{
try
{
_db.Trades.Add(t);
await _db.SaveChangesAsync(ct);
}
catch
{
try { _db.Entry(t).State = EntityState.Detached; } catch { }
}
}
}
}