Browse Source

Update Fastest

pull/10/head
sunkaixuna 3 years ago
parent
commit
f8fa0d7708
  1. 24
      Src/Asp.Net/SqlSugar/Abstract/FastestProvider/FastestProvider.cs
  2. 1
      Src/Asp.Net/SqlSugar/Interface/IFastest.cs

24
Src/Asp.Net/SqlSugar/Abstract/FastestProvider/FastestProvider.cs

@ -10,7 +10,7 @@ namespace SqlSugar
{
private SqlSugarProvider context;
private ISugarQueryable<T> queryable;
private string AsName { get; set; }
public FastestProvider(SqlSugarProvider sqlSugarProvider)
{
this.context = sqlSugarProvider;
@ -28,7 +28,11 @@ namespace SqlSugar
var result = await buider.ExecuteBulkCopyAsync(dt);
return result;
}
public IFastest<T> AS(string tableName)
{
this.AsName = tableName;
return this;
}
private DataTable ToDdateTable(List<T> datas)
{
DataTable tempDataTable = ReflectionInoCore<DataTable>.GetInstance().GetOrCreate("BulkCopyAsync" + typeof(T).FullName, () => queryable.Where(it => false).ToDataTable());
@ -38,7 +42,7 @@ namespace SqlSugar
dt.Columns.Add(item.ColumnName, item.DataType);
}
var entityInfo = this.context.EntityMaintenance.GetEntityInfo<T>();
dt.TableName = queryable.SqlBuilder.GetTranslationTableName(entityInfo.DbTableName);
GetTableName(dt, entityInfo);
var columns = entityInfo.Columns;
foreach (var item in datas)
{
@ -62,6 +66,18 @@ namespace SqlSugar
return dt;
}
private void GetTableName(DataTable dt, EntityInfo entityInfo)
{
if (this.AsName.HasValue())
{
dt.TableName = queryable.SqlBuilder.GetTranslationTableName(AsName);
}
else
{
dt.TableName = queryable.SqlBuilder.GetTranslationTableName(entityInfo.DbTableName);
}
}
private object ValueConverter(EntityColumnInfo columnInfo,object value)
{
if (value == null)
@ -72,5 +88,7 @@ namespace SqlSugar
}
return value;
}
}
}

1
Src/Asp.Net/SqlSugar/Interface/IFastest.cs

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

Loading…
Cancel
Save