C#: Limit the rows an update or delete affects

Sets the most rows an Update() or Delete() may affect. If the mutation would affect more rows, PostgREST rolls it back and the call throws.

Examples

Cap a delete

await supabase
  .From<City>()
  .Filter("country_id", Operator.Equals, "554")
  .MaxAffected(10)
  .Delete();

Handle the limit being exceeded

try
{
    await supabase
      .From<City>()
      .Where(x => x.CountryId == 554)
      .Set(x => x.Name, "Renamed")
      .MaxAffected(5)
      .Update();
}
catch (PostgrestException ex) when (ex.Reason == FailureHint.Reason.MaxAffectedExceeded)
{
    // More than 5 rows matched, nothing was changed.
}