From f8fa0d770821e3cc09203334f94c0e2a5b6f19e5 Mon Sep 17 00:00:00 2001 From: sunkaixuna <610262374@qq.com> Date: Thu, 18 Nov 2021 01:06:52 +0800 Subject: [PATCH] Update Fastest --- .../FastestProvider/FastestProvider.cs | 24 ++++++++++++++++--- Src/Asp.Net/SqlSugar/Interface/IFastest.cs | 5 ++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Src/Asp.Net/SqlSugar/Abstract/FastestProvider/FastestProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/FastestProvider/FastestProvider.cs index 542b42521..5a2637d5a 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/FastestProvider/FastestProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/FastestProvider/FastestProvider.cs @@ -10,7 +10,7 @@ namespace SqlSugar { private SqlSugarProvider context; private ISugarQueryable 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 AS(string tableName) + { + this.AsName = tableName; + return this; + } private DataTable ToDdateTable(List datas) { DataTable tempDataTable = ReflectionInoCore.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(); - 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; } + + } } diff --git a/Src/Asp.Net/SqlSugar/Interface/IFastest.cs b/Src/Asp.Net/SqlSugar/Interface/IFastest.cs index 5c62a45e9..9a784b72c 100644 --- a/Src/Asp.Net/SqlSugar/Interface/IFastest.cs +++ b/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 { + IFastest AS(string tableName); int BulkCopy(List datas); - Task BulkCopyAsync(List datas); + Task BulkCopyAsync(List datas); } }