update db.Fastest

This commit is contained in:
sunkaixuna
2021-11-22 11:47:20 +08:00
parent 9ab45c089a
commit dec730190a
5 changed files with 13 additions and 3 deletions

View File

@@ -93,6 +93,7 @@ namespace SqlSugar
var result = await buider.UpdateByTempAsync(GetTableName(), dt.TableName, updateColumns, whereColumns);
this.context.DbMaintenance.DropTable(dt.TableName);
this.context.CurrentConnectionConfig.IsAutoCloseConnection = isAuto;
buider.CloseDb();
End(datas);
return result;
}

View File

@@ -13,5 +13,6 @@ namespace SqlSugar
Task<int> UpdateByTempAsync(string tableName,string tempName,string [] updateColumns,string[] whereColumns);
Task<int> ExecuteBulkCopyAsync(DataTable dt);
Task CreateTempAsync<T>(DataTable dt) where T : class, new();
void CloseDb();
}
}

View File

@@ -8,7 +8,7 @@ namespace SqlSugar
public interface IFastest<T>
{
IFastest<T> AS(string tableName);
IFastest<T> PageSize(int Size);
int BulkCopy(List<T> datas);
Task<int> BulkCopyAsync(List<T> datas);

View File

@@ -16,6 +16,11 @@ namespace SqlSugar
public SqlSugarProvider Context { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public void CloseDb()
{
throw new NotImplementedException();
}
public Task CreateTempAsync<T>(DataTable dt) where T : class, new()
{
throw new NotImplementedException();

View File

@@ -44,7 +44,7 @@ namespace SqlSugar
try
{
var identityColumnInfo = this.entityInfo.Columns.FirstOrDefault(it => it.IsIdentity);
if (identityColumnInfo!=null)
if (identityColumnInfo != null)
{
throw new Exception("PgSql bulkcopy no support identity");
}
@@ -52,9 +52,12 @@ namespace SqlSugar
}
catch (Exception ex)
{
base.CloseDb();
throw ex;
}
finally
{
base.CloseDb();
}
return await Task.FromResult(dt.Rows.Count);
}