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.
Join Stack Overflow to learn, share knowledge, and build your career.
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.
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.
condition
is wide enough, then you will automatically update more than one record. – Peter Abolins Jun 5 '18 at 7:46BulkUpdateAsync
. Or use EFCore.BulkExtensions – vivek nuna Jun 5 '18 at 11:13