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. 5
      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;
}
}
}

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

@ -3,11 +3,12 @@ using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
namespace SqlSugar
{
public interface IFastest<T>
{
IFastest<T> AS(string tableName);
int BulkCopy(List<T> datas);
Task<int> BulkCopyAsync(List<T> datas);
Task<int> BulkCopyAsync(List<T> datas);
}
}

Loading…
Cancel
Save