Update db.InsertNav

This commit is contained in:
sunkaixuan
2022-08-03 10:15:15 +08:00
parent cc580bf62d
commit c5b29149e8
2 changed files with 19 additions and 3 deletions

View File

@@ -31,7 +31,17 @@ namespace SqlSugar
}
public InsertNavProvider<Root, TChild> ThenInclude<TChild>(Expression<Func<T, TChild>> expression) where TChild : class, new()
{
return _ThenInclude(expression);
}
public InsertNavProvider<Root, TChild> ThenInclude<TChild>(Expression<Func<T, List<TChild>>> expression) where TChild : class, new()
{
return _ThenInclude(expression);
}
private InsertNavProvider<Root, TChild> _ThenInclude<TChild>(Expression<Func<T, TChild>> expression) where TChild : class, new()
{
var name = ExpressionTool.GetMemberName(expression);
if (this._ParentEntity == null)
{
@@ -61,7 +71,8 @@ namespace SqlSugar
}
return GetResult<TChild>();
}
public InsertNavProvider<Root, TChild> ThenInclude<TChild>(Expression<Func<T,List<TChild>>> expression) where TChild : class, new()
private InsertNavProvider<Root, TChild> _ThenInclude<TChild>(Expression<Func<T, List<TChild>>> expression) where TChild : class, new()
{
var name = ExpressionTool.GetMemberName(expression);
if (this._ParentEntity == null)
@@ -70,7 +81,7 @@ namespace SqlSugar
IsFirst = true;
}
var nav = this._ParentEntity.Columns.FirstOrDefault(x => x.PropertyName == name);
;
;
if (nav.Navigat == null)
{

View File

@@ -16,4 +16,9 @@ namespace SqlSugar
public bool ManyToManyIsUpdateA { get; set; }
public bool ManyToManyIsUpdateB { get; set; }
}
public class InsertNavOptions
{
public bool OneToManyIfExistsNoInsert { get; set; }
}
}