Browse Source

Optimized code

pull/33/head
sunkaixuan 2 years ago
parent
commit
d49261fac9
  1. 17
      Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSql.cs

17
Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSql.cs

@ -752,22 +752,9 @@ namespace SqlSugar
} }
public int IntoTable(Type TableEntityType) public int IntoTable(Type TableEntityType)
{ {
var entityInfo=this.Context.EntityMaintenance.GetEntityInfo(TableEntityType); var entityInfo = this.Context.EntityMaintenance.GetEntityInfo(TableEntityType);
var sqlInfo=this.ToSql();
var name = this.SqlBuilder.GetTranslationTableName(entityInfo.DbTableName); var name = this.SqlBuilder.GetTranslationTableName(entityInfo.DbTableName);
var columns = ""; return IntoTable(TableEntityType, name);
if (this.QueryBuilder.GetSelectValue != null && this.QueryBuilder.GetSelectValue.Contains(",")) ;
{
columns = "(";
foreach (var item in this.QueryBuilder.GetSelectValue.Split(','))
{
var column = Regex.Split(item,"AS").Last().Trim();
columns += $"{column},";
}
columns = columns.TrimEnd(',') + ")";
}
var sql= $" INSERT INTO {name} {columns} " + sqlInfo.Key;
return this.Context.Ado.ExecuteCommand(sql, sqlInfo.Value);
} }
public int IntoTable(Type TableEntityType,string TableName) public int IntoTable(Type TableEntityType,string TableName)

Loading…
Cancel
Save