Synchronization code

This commit is contained in:
sunkaixuan 2025-01-13 13:59:24 +08:00
parent 02533af0ee
commit 63e9863df7
2 changed files with 16 additions and 3 deletions

View File

@ -51,7 +51,20 @@ namespace SqlSugar
public async virtual Task<int> Merge<T>(string tableName,DataTable dt, EntityInfo entityInfo, string[] whereColumns, string[] updateColumns, List<T> datas) where T : class, new()
{
var result = 0;
await this.Context.Utilities.PageEachAsync(datas,2000,async pageItems =>
var pageSize = 2000;
if (dt.Columns.Count > 100)
{
pageSize = 100;
}
else if (dt.Columns.Count > 50)
{
pageSize = 300;
}
else if (dt.Columns.Count > 30)
{
pageSize = 500;
}
await this.Context.Utilities.PageEachAsync(datas, pageSize, async pageItems =>
{
var x = await this.Context.Storageable(pageItems).As(tableName).WhereColumns(whereColumns).ToStorageAsync();
result += await x.BulkCopyAsync();

View File

@ -80,8 +80,8 @@ namespace SqlSugar
}
public QueryMethodInfo AddJoinInfo(Type joinEntityType, string shortName, string onWhere, JoinType type = JoinType.Left)
{
var method = QueryableObj.GetType().GetMyMethod("AddJoinInfo", 4, typeof(string), typeof(string), typeof(string), typeof(JoinType));
this.QueryableObj = method.Invoke(QueryableObj, new object[] { this.Context.EntityMaintenance.GetTableName(joinEntityType), shortName, onWhere, type });
var method = QueryableObj.GetType().GetMyMethod("AddJoinInfo", 4, typeof(Type), typeof(string), typeof(string), typeof(JoinType));
this.QueryableObj = method.Invoke(QueryableObj, new object[] { joinEntityType, shortName, onWhere, type });
return this;
}
public QueryMethodInfo GroupBy(List<GroupByModel> models)