Search code examples
sqlasp.net-coreentity-framework-coreaspnetboilerplate

how to update the multiple rows at a time in aspnetboilerplate?


I want to execute the SQL clause like:

UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;

Because I want to update multiple rows in database. But I don't know how to implement this.


Solution

  • I have found the solution. Using the extension method GetDbContext of Repository to get the DbContext, then using the DbContext.Database.ExecuteSqlCommandAsync to execute raw SQL.