mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 13:34:32 +08:00
Questdb bulk copy support pagesize
This commit is contained in:
parent
fa6c7ffd9f
commit
9cfd9c0c23
@ -0,0 +1,38 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SqlSugar
|
||||||
|
{
|
||||||
|
public class QuestDbPageSizeBulkCopy
|
||||||
|
{
|
||||||
|
private QuestDbRestAPI questDbRestAPI;
|
||||||
|
private int pageSize;
|
||||||
|
private ISqlSugarClient db;
|
||||||
|
public QuestDbPageSizeBulkCopy(QuestDbRestAPI questDbRestAPI, int pageSize, ISqlSugarClient db)
|
||||||
|
{
|
||||||
|
this.questDbRestAPI = questDbRestAPI;
|
||||||
|
this.pageSize = pageSize;
|
||||||
|
this.db = db;
|
||||||
|
}
|
||||||
|
public int BulkCopy<T>(List<T> insertDatas, string dateFormat = "yyyy/M/d H:mm:ss") where T : class, new()
|
||||||
|
{
|
||||||
|
int result = 0;
|
||||||
|
db.Utilities.PageEach(insertDatas, pageSize, pageItems =>
|
||||||
|
{
|
||||||
|
result+=questDbRestAPI.BulkCopyAsync(pageItems, dateFormat).GetAwaiter().GetResult();
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public async Task<int> BulkCopyAsync<T>(List<T> insertDatas, string dateFormat = "yyyy/M/d H:mm:ss") where T : class, new()
|
||||||
|
{
|
||||||
|
int result = 0;
|
||||||
|
await db.Utilities.PageEachAsync(insertDatas, pageSize, async pageItems =>
|
||||||
|
{
|
||||||
|
result +=await questDbRestAPI.BulkCopyAsync(pageItems, dateFormat);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -92,6 +92,11 @@ namespace SqlSugar
|
|||||||
return BulkCopyAsync(insertData, dateFormat).GetAwaiter().GetResult();
|
return BulkCopyAsync(insertData, dateFormat).GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public QuestDbPageSizeBulkCopy PageSize(int pageSize)
|
||||||
|
{
|
||||||
|
QuestDbPageSizeBulkCopy result = new QuestDbPageSizeBulkCopy(this,pageSize,db);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 批量快速插入异步
|
/// 批量快速插入异步
|
||||||
|
Loading…
Reference in New Issue
Block a user