Fix DbUpdateException in TradeRepository and Polymarket API 400 on max offset
This commit is contained in:
@@ -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 { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user