Browse Source

Update InsertNav

pull/23/head
sunkaixuan 2 years ago
parent
commit
406d83a92b
  1. 36
      Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/InsertNavProviderHelper.cs
  2. 6
      Src/Asp.Net/SqlSugar/Entities/DeleteNavOptions.cs

36
Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/InsertNavProviderHelper.cs

@ -58,7 +58,17 @@ namespace SqlSugar
{
foreach (var item in datas)
{
this._Context.Insertable(item).ExecuteCommandIdentityIntoEntity();
if (IsFirst&&_RootOptions!=null)
{
this._Context.Insertable(item)
.IgnoreColumns(_RootOptions.IgnoreColumns)
.InsertColumns(_RootOptions.InsertColumns)
.ExecuteCommandIdentityIntoEntity();
}
else
{
this._Context.Insertable(item).ExecuteCommandIdentityIntoEntity();
}
}
}
@ -142,7 +152,17 @@ namespace SqlSugar
pkColumn.PropertyInfo.SetValue(child, value());
}
}
this._Context.Insertable(insertData).ExecuteCommand();
if (IsFirst && _RootOptions != null)
{
this._Context.Insertable(insertData)
.IgnoreColumns(_RootOptions.IgnoreColumns)
.InsertColumns(_RootOptions.InsertColumns)
.ExecuteCommand();
}
else
{
this._Context.Insertable(insertData).ExecuteCommand();
}
}
private void SetError<TChild>(EntityColumnInfo pkColumn, List<TChild> insertData) where TChild : class, new()
{
@ -154,7 +174,17 @@ namespace SqlSugar
Check.ExceptionEasy($"The field {name} is not an autoassignment type and requires an assignment", $"字段{name}不是可自动赋值类型需要赋值(并且不能是已存在值) , 可赋值类型有 自增、long、Guid、string");
}
}
this._Context.Insertable(insertData).ExecuteCommand();
if (IsFirst && _RootOptions != null)
{
this._Context.Insertable(insertData)
.IgnoreColumns(_RootOptions.IgnoreColumns)
.InsertColumns(_RootOptions.InsertColumns)
.ExecuteCommand();
}
else
{
this._Context.Insertable(insertData).ExecuteCommand();
}
}
}
}

6
Src/Asp.Net/SqlSugar/Entities/DeleteNavOptions.cs

@ -14,12 +14,12 @@ namespace SqlSugar
}
public class InsertNavRootOptions
{
public string IgnoreColumns { get; set; }
public string[] UpdateColumns { get; set; }
public string[] IgnoreColumns { get; set; }
public string[] InsertColumns { get; set; }
}
public class InertNavRootOptions
{
public string IgnoreColumns { get; set; }
public string[] IgnoreColumns { get; set; }
public string[] InsertColumns { get; set; }
}
public class UpdateNavRootOptions

Loading…
Cancel
Save