mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-20 02:29:39 +08:00
Update nav
This commit is contained in:
@@ -74,7 +74,16 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
children = children.Distinct().ToList();
|
children = children.Distinct().ToList();
|
||||||
Check.ExceptionEasy(pkColumn == null, typeof(TChild).Name + " has no primary key", typeof(TChild).Name + "没有主键");
|
Check.ExceptionEasy(pkColumn == null, typeof(TChild).Name + " has no primary key", typeof(TChild).Name + "没有主键");
|
||||||
; var x = this._Context.Storageable(children).WhereColumns(new string[] { pkColumn.PropertyName }).ToStorage();
|
var whereName = pkColumn.PropertyName;
|
||||||
|
if (_Options.OneToOneSaveByPrimaryKey&& pkColumn.IsPrimarykey==false)
|
||||||
|
{
|
||||||
|
var newPkColumn=this._Context.EntityMaintenance.GetEntityInfo<TChild>().Columns.FirstOrDefault(it => it.IsPrimarykey);
|
||||||
|
if (newPkColumn != null)
|
||||||
|
{
|
||||||
|
whereName = newPkColumn.PropertyName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
; var x = this._Context.Storageable(children).WhereColumns(new string[] {whereName}).ToStorage();
|
||||||
var insertData = x.InsertList.Select(it => it.Item).ToList();
|
var insertData = x.InsertList.Select(it => it.Item).ToList();
|
||||||
var updateData = x.UpdateList.Select(it => it.Item).ToList();
|
var updateData = x.UpdateList.Select(it => it.Item).ToList();
|
||||||
Check.ExceptionEasy(pkColumn == null && NavColumn == null, $"The entity is invalid", $"实体错误无法使用导航");
|
Check.ExceptionEasy(pkColumn == null && NavColumn == null, $"The entity is invalid", $"实体错误无法使用导航");
|
||||||
|
@@ -56,6 +56,7 @@ namespace SqlSugar
|
|||||||
public Expression CurrentFunc { get; set; }
|
public Expression CurrentFunc { get; set; }
|
||||||
public string[] IgnoreColumns { get; set; }
|
public string[] IgnoreColumns { get; set; }
|
||||||
public bool IgnoreNullColumns { get; set; }
|
public bool IgnoreNullColumns { get; set; }
|
||||||
|
public bool OneToOneSaveByPrimaryKey { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class InsertNavOptions
|
public class InsertNavOptions
|
||||||
|
Reference in New Issue
Block a user