mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-16 16:50:41 +08:00
Add Check
This commit is contained in:
parent
79165de458
commit
561abf8fae
@ -94,6 +94,10 @@ namespace SqlSugar
|
|||||||
private void InsertDatas<TChild>(List<TChild> children, EntityColumnInfo pkColumn, EntityColumnInfo NavColumn=null) where TChild : class, new()
|
private void InsertDatas<TChild>(List<TChild> children, EntityColumnInfo pkColumn, EntityColumnInfo NavColumn=null) where TChild : class, new()
|
||||||
{
|
{
|
||||||
children = children.Distinct().ToList();
|
children = children.Distinct().ToList();
|
||||||
|
if (pkColumn == null)
|
||||||
|
{
|
||||||
|
Check.ExceptionEasy($"{typeof(TChild).Name} need primary key ", $"{typeof(TChild).Name}需要主键");
|
||||||
|
}
|
||||||
var x = this._Context.Storageable(children).WhereColumns(new string[] { pkColumn.PropertyName }).ToStorage();
|
var x = this._Context.Storageable(children).WhereColumns(new string[] { pkColumn.PropertyName }).ToStorage();
|
||||||
var insertData = children = x.InsertList.Select(it => it.Item).ToList();
|
var insertData = children = x.InsertList.Select(it => it.Item).ToList();
|
||||||
var IsNoExistsNoInsert = _navOptions != null && _navOptions.OneToManyIfExistsNoInsert == true;
|
var IsNoExistsNoInsert = _navOptions != null && _navOptions.OneToManyIfExistsNoInsert == true;
|
||||||
|
Loading…
Reference in New Issue
Block a user