mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-21 07:40:57 +08:00
update
@@ -250,6 +250,20 @@ The benefits of using this program for dang complex update:
|
||||
- Data can be previewed before updating to prevent wrong update operations;
|
||||
- Support complex update operations, for example: Use `Limit(10)` on `ISelect` to update the first 10 records that meet the conditions;
|
||||
|
||||
## 11、BulkCopy Batch Update
|
||||
|
||||
FreeSql.Provider.SqlServer、FreeSql.Provider.MySqlConnector、FreeSql.Provider. PostgreSQL
|
||||
|
||||
The extension methods ExecuteSqlBulkCopy, ExecuteMySqlBulkCopy, and ExecutePgCopy are implemented to implement batch update (v3.2.685)
|
||||
|
||||
Principle: Use BulkCopy to insert data into the temporary table, and then use UPDATE FROM JOIN to update the associated table.
|
||||
|
||||
Tip: When the number of updated fields exceeds 3000, the benefits are large.
|
||||
|
||||
```csharp
|
||||
fsql.Update<T1>().SetSource(list).ExecuteSqlBulkCopy();
|
||||
```
|
||||
|
||||
## Reference
|
||||
|
||||
- [《Database Transaction》](Database-Transaction)
|
||||
|
||||
14
修改.md
14
修改.md
@@ -251,6 +251,20 @@ UPDATE `T1` SET Title = '111' WHERE id in (select a.id from T1 a left join Optio
|
||||
- 更新前可预览测试数据,防止错误更新操作;
|
||||
- 支持复杂的更新操作,例如:`ISelect` 上使用 `Limit(10)` 更新附合条件的前 10 条记录;
|
||||
|
||||
## 11、BulkCopy 批量更新
|
||||
|
||||
FreeSql.Provider.SqlServer、FreeSql.Provider.MySqlConnector、FreeSql.Provider.PostgreSQL
|
||||
|
||||
分别实现了扩展方法 ExecuteSqlBulkCopy、ExecuteMySqlBulkCopy、ExecutePgCopy 实现批量更新(v3.2.685)
|
||||
|
||||
原理:使用 BulkCopy 将数据插入到临时表,再使用 UPDATE FROM JOIN 联表更新。
|
||||
|
||||
提示:当更新的字段数量超过 3000 时,收益较大。
|
||||
|
||||
```csharp
|
||||
fsql.Update<T1>().SetSource(list).ExecuteSqlBulkCopy();
|
||||
```
|
||||
|
||||
## 参考资料
|
||||
|
||||
- [《数据库事务》](%e4%ba%8b%e5%8a%a1)
|
||||
|
||||
Reference in New Issue
Block a user