Browse Source

Synchronization code

pull/29/head
sunkaixuan 2 years ago
parent
commit
2fa0fda4b5
  1. 11
      Src/Asp.NetCore2/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs
  2. 2
      Src/Asp.NetCore2/SqlSugar/Abstract/InsertableProvider/ParameterInsertable.cs
  3. 5
      Src/Asp.NetCore2/SqlSugar/Abstract/SqlBuilderProvider/InsertBuilder.cs

11
Src/Asp.NetCore2/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs

@ -424,16 +424,7 @@ namespace SqlSugar
} }
public IInsertable<T> AS(string tableName) public IInsertable<T> AS(string tableName)
{ {
if (tableName == null) return this; this.InsertBuilder.AsName = tableName;
var entityName = typeof(T).Name;
IsAs = true;
OldMappingTableList = this.Context.MappingTables;
this.Context.MappingTables = this.Context.Utilities.TranslateCopy(this.Context.MappingTables);
if (this.Context.MappingTables.Any(it => it.EntityName == entityName))
{
this.Context.MappingTables.Add(this.Context.MappingTables.First(it => it.EntityName == entityName).DbTableName, tableName);
}
this.Context.MappingTables.Add(entityName, tableName);
return this; ; return this; ;
} }
public IInsertable<T> IgnoreColumns(Expression<Func<T, object>> columns) public IInsertable<T> IgnoreColumns(Expression<Func<T, object>> columns)

2
Src/Asp.NetCore2/SqlSugar/Abstract/InsertableProvider/ParameterInsertable.cs

@ -49,6 +49,7 @@ namespace SqlSugar
var itemable = this.Context.Insertable(item); var itemable = this.Context.Insertable(item);
itemable.InsertBuilder.DbColumnInfoList = itemable.InsertBuilder.DbColumnInfoList.Where(it => columns.Contains(it.DbColumnName)).ToList(); itemable.InsertBuilder.DbColumnInfoList = itemable.InsertBuilder.DbColumnInfoList.Where(it => columns.Contains(it.DbColumnName)).ToList();
itemable.InsertBuilder.TableWithString = tableWithString; itemable.InsertBuilder.TableWithString = tableWithString;
itemable.InsertBuilder.AsName = Inserable.InsertBuilder.AsName;
(itemable as InsertableProvider<T>).RemoveCacheFunc = removeCacheFunc; (itemable as InsertableProvider<T>).RemoveCacheFunc = removeCacheFunc;
itemable.AddQueue(); itemable.AddQueue();
} }
@ -77,6 +78,7 @@ namespace SqlSugar
var itemable = this.Context.Insertable(item); var itemable = this.Context.Insertable(item);
itemable.InsertBuilder.DbColumnInfoList = itemable.InsertBuilder.DbColumnInfoList.Where(it => columns.Contains(it.DbColumnName)).ToList(); itemable.InsertBuilder.DbColumnInfoList = itemable.InsertBuilder.DbColumnInfoList.Where(it => columns.Contains(it.DbColumnName)).ToList();
itemable.InsertBuilder.TableWithString = tableWithString; itemable.InsertBuilder.TableWithString = tableWithString;
itemable.InsertBuilder.AsName = Inserable.InsertBuilder.AsName;
(itemable as InsertableProvider<T>).RemoveCacheFunc = removeCacheFunc; (itemable as InsertableProvider<T>).RemoveCacheFunc = removeCacheFunc;
itemable.AddQueue(); itemable.AddQueue();
} }

5
Src/Asp.NetCore2/SqlSugar/Abstract/SqlBuilderProvider/InsertBuilder.cs

@ -35,6 +35,7 @@ namespace SqlSugar
public virtual bool IsNoPage { get; set; } public virtual bool IsNoPage { get; set; }
public virtual bool IsReturnPkList { get; set; } public virtual bool IsReturnPkList { get; set; }
public string AsName { get; set; }
#endregion #endregion
#region SqlTemplate #region SqlTemplate
@ -115,6 +116,10 @@ namespace SqlSugar
{ {
get get
{ {
if (AsName.HasValue())
{
return Builder.GetTranslationTableName(AsName);
}
var result = Builder.GetTranslationTableName(EntityInfo.EntityName); var result = Builder.GetTranslationTableName(EntityInfo.EntityName);
result += UtilConstants.Space; result += UtilConstants.Space;
if (this.TableWithString.HasValue()) if (this.TableWithString.HasValue())

Loading…
Cancel
Save