Update InsertNav

This commit is contained in:
sunkaixuan
2022-10-24 09:44:45 +08:00
parent adbf0ad3eb
commit 406d83a92b
2 changed files with 36 additions and 6 deletions

View File

@@ -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();
}
}
}
}

View File

@@ -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