dotConnect for Snowflake Documentation
On this page
    Bulk Operations and Performance
    On this page

    dotConnect for Snowflake executes each INSERT, UPDATE, and DELETE statement generated by SaveChanges as a separate request. This topic describes how to modify multiple rows efficiently and how to reduce the cost of queries.

    Update and Delete Multiple Rows

    To update or delete multiple rows efficiently, use the ExecuteUpdate and ExecuteDelete methods. They are available in the provider builds for Entity Framework Core 8 and later. Each method translates the operation into a single UPDATE or DELETE statement without loading entities into memory or using the change tracker:

    int updated = context.Products
      .Where(p => p.Price < 100)
      .ExecuteUpdate(s => s.SetProperty(p => p.Price, p => p.Price * 1.1m));
    
    int deleted = context.Orders
      .Where(o => o.Customer.Name == "Jones")
      .ExecuteDelete();
    

    A filter by a navigation property, as in the second statement, is translated to a subquery: DELETE ... WHERE "Id" IN (SELECT ... JOIN ...). ExecuteUpdate can also assign JSON text to a VARIANT, OBJECT, or ARRAY column.

    The ExecuteUpdate and ExecuteDelete methods execute immediately, without calling SaveChanges. They don't update tracked entities and don't apply optimistic concurrency control. Don't mix them with changes to the same rows that you save with SaveChanges: otherwise, SaveChanges can overwrite the changes made by these methods.

    Performance Recommendations

    For general performance recommendations, see Performance Optimization.