枚举转字典时,对sqlite、pg、mysql、sqlserver采用批量处理
This commit is contained in:
parent
0dd6bb2967
commit
febb2f360c
@ -123,30 +123,54 @@ public class SysEnumService : IDynamicApiController, ITransient
|
|||||||
var newEnumType = enumTypeList.Where(u => !updatedEnumCodes.Contains(u.TypeName)).ToList();
|
var newEnumType = enumTypeList.Where(u => !updatedEnumCodes.Contains(u.TypeName)).ToList();
|
||||||
var (newDictTypes, newDictDatas) = GetNewSysDicts(newEnumType);
|
var (newDictTypes, newDictDatas) = GetNewSysDicts(newEnumType);
|
||||||
|
|
||||||
|
// 若是sqlite、pg、mysql、sqlserver则采用批量处理
|
||||||
|
bool useBulk = _db.CurrentConnectionConfig.DbType == SqlSugar.DbType.Sqlite
|
||||||
|
|| _db.CurrentConnectionConfig.DbType == SqlSugar.DbType.PostgreSQL
|
||||||
|
|| _db.CurrentConnectionConfig.DbType == SqlSugar.DbType.MySql
|
||||||
|
|| _db.CurrentConnectionConfig.DbType == SqlSugar.DbType.MySqlConnector
|
||||||
|
|| _db.CurrentConnectionConfig.DbType == SqlSugar.DbType.SqlServer;
|
||||||
|
|
||||||
// 执行数据库操作
|
// 执行数据库操作
|
||||||
if (updatedDictTypes.Count > 0)
|
if (updatedDictTypes.Count > 0)
|
||||||
await _db.Updateable(updatedDictTypes).ExecuteCommandAsync();
|
{
|
||||||
|
if (useBulk) await _db.Fastest<SysDictType>().PageSize(300).BulkMergeAsync(updatedDictTypes);
|
||||||
|
else await _db.Updateable(updatedDictTypes).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
|
||||||
if (updatedDictDatas.Count > 0)
|
if (updatedDictDatas.Count > 0)
|
||||||
await _db.Updateable(updatedDictDatas).ExecuteCommandAsync();
|
{
|
||||||
|
if (useBulk) await _db.Fastest<SysDictData>().PageSize(300).BulkMergeAsync(updatedDictDatas);
|
||||||
|
else await _db.Updateable(updatedDictDatas).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
|
||||||
if (newSysDictDatas.Count > 0)
|
if (newSysDictDatas.Count > 0)
|
||||||
{
|
{
|
||||||
// 达梦:用db.Insertable(newDictTypes).ExecuteCommandAsync(stoppingToken);插入400条以上会内容溢出错误,所以改用逐条插入
|
if (useBulk) await _db.Fastest<SysDictData>().PageSize(300).BulkMergeAsync(newSysDictDatas);
|
||||||
// 达梦:不支持storageable2.BulkUpdateAsync 功能
|
else
|
||||||
foreach (var dd in newSysDictDatas)
|
{
|
||||||
await _db.Insertable(dd).ExecuteCommandAsync();
|
// 达梦:用db.Insertable(newSysDictDatas).ExecuteCommandAsync(stoppingToken);插入400条以上会内容溢出错误,所以改用逐条插入
|
||||||
|
// 达梦:不支持storageable2.BulkUpdateAsync 功能
|
||||||
|
foreach (var dd in newSysDictDatas)
|
||||||
|
await _db.Insertable(dd).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newDictTypes.Count > 0)
|
if (newDictTypes.Count > 0)
|
||||||
await _db.Insertable(newDictTypes).ExecuteCommandAsync();
|
{
|
||||||
|
if (useBulk) await _db.Fastest<SysDictType>().PageSize(300).BulkMergeAsync(newDictTypes);
|
||||||
|
else await _db.Insertable(newDictTypes).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
|
||||||
if (newDictDatas.Count > 0)
|
if (newDictDatas.Count > 0)
|
||||||
{
|
{
|
||||||
// 达梦:用db.Insertable(newDictTypes).ExecuteCommandAsync(stoppingToken);插入400条以上会内容溢出错误,所以改用逐条插入
|
if (useBulk) await _db.Fastest<SysDictData>().PageSize(300).BulkMergeAsync(newDictDatas);
|
||||||
// 达梦:不支持storageable2.BulkUpdateAsync 功能
|
else
|
||||||
foreach (var dd in newDictDatas)
|
{
|
||||||
await _db.Insertable(dd).ExecuteCommandAsync();
|
// 达梦:用db.Insertable(newDictDatas).ExecuteCommandAsync(stoppingToken);插入400条以上会内容溢出错误,所以改用逐条插入
|
||||||
|
// 达梦:不支持storageable2.BulkUpdateAsync 功能
|
||||||
|
foreach (var dd in newDictDatas)
|
||||||
|
await _db.Insertable(dd).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user