mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Update Fastest
This commit is contained in:
parent
9f2bae2a57
commit
f8fa0d7708
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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…
Reference in New Issue
Block a user