如何在 aspnetboilerplate 中一次更新多行?
how to update the multiple rows at a time in aspnetboilerplate?
我想像这样执行 SQL 子句:
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
因为我想更新数据库中的多行。但是我不知道如何实现这个。
我找到了解决办法。使用Repository
的扩展方法GetDbContext
获取DbContext
,然后使用DbContext.Database.ExecuteSqlCommandAsync
执行raw SQL.
我想像这样执行 SQL 子句:
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
因为我想更新数据库中的多行。但是我不知道如何实现这个。
我找到了解决办法。使用Repository
的扩展方法GetDbContext
获取DbContext
,然后使用DbContext.Database.ExecuteSqlCommandAsync
执行raw SQL.