mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
Synchronization code
This commit is contained in:
parent
9b4162d840
commit
8aca0f0f2b
@ -43,6 +43,22 @@ namespace SqlSugar
|
||||
}
|
||||
return methodInfo;
|
||||
}
|
||||
public InsertNavMethodInfo IncludesAllFirstLayer(InsertNavOptions insertNavOptions,params string[] ignoreColumns)
|
||||
{
|
||||
if (ignoreColumns == null)
|
||||
{
|
||||
ignoreColumns = new string[] { };
|
||||
}
|
||||
this.Context = insertNavProvider._Context;
|
||||
var navColumns = this.Context.EntityMaintenance.GetEntityInfo<Root>().Columns.Where(it => !ignoreColumns.Contains(it.PropertyName) || !ignoreColumns.Any(z => z.EqualCase(it.DbColumnName))).Where(it => it.Navigat != null).ToList();
|
||||
var updateNavs = this;
|
||||
InsertNavMethodInfo methodInfo = updateNavs.IncludeByNameString(navColumns[0].PropertyName);
|
||||
foreach (var item in navColumns.Skip(1))
|
||||
{
|
||||
methodInfo = methodInfo.IncludeByNameString(item.PropertyName, insertNavOptions);
|
||||
}
|
||||
return methodInfo;
|
||||
}
|
||||
public InsertNavTask<Root, TChild> Include<TChild>(Expression<Func<Root, TChild>> expression) where TChild : class, new()
|
||||
{
|
||||
Check.ExceptionEasy(typeof(TChild).FullName.Contains("System.Collections.Generic.List`"), " need where T: class, new() ", "需要Class,new()约束,并且类属性中不能有required修饰符");
|
||||
|
@ -11,7 +11,7 @@ namespace SqlSugar
|
||||
internal object MethodInfos { get; set; }
|
||||
internal SqlSugarProvider Context { get; set; }
|
||||
|
||||
public InsertNavMethodInfo IncludeByNameString(string navMemberName, InsertNavRootOptions updateNavOptions = null)
|
||||
public InsertNavMethodInfo IncludeByNameString(string navMemberName, InsertNavOptions insertNavOptions = null)
|
||||
{
|
||||
var type = MethodInfos.GetType().GetGenericArguments()[0];
|
||||
var entityInfo = this.Context.EntityMaintenance.GetEntityInfo(type);
|
||||
@ -20,11 +20,11 @@ namespace SqlSugar
|
||||
Expression exp = UtilMethods.GetIncludeExpression(navMemberName, entityInfo, out properyItemType, out isList);
|
||||
var method = this.MethodInfos.GetType().GetMyMethod("Include", 2, isList)
|
||||
.MakeGenericMethod(properyItemType);
|
||||
var obj = method.Invoke(this.MethodInfos, new object[] { exp, updateNavOptions });
|
||||
var obj = method.Invoke(this.MethodInfos, new object[] { exp, insertNavOptions });
|
||||
this.MethodInfos = obj;
|
||||
return this;
|
||||
}
|
||||
public InsertNavMethodInfo ThenIncludeByNameString(string navMemberName, InsertNavRootOptions updateNavOptions = null)
|
||||
public InsertNavMethodInfo ThenIncludeByNameString(string navMemberName, InsertNavOptions insertNavOptions = null)
|
||||
{
|
||||
var type = MethodInfos.GetType().GetGenericArguments()[1];
|
||||
var entityInfo = this.Context.EntityMaintenance.GetEntityInfo(type);
|
||||
@ -33,7 +33,7 @@ namespace SqlSugar
|
||||
Expression exp = UtilMethods.GetIncludeExpression(navMemberName, entityInfo, out properyItemType, out isList);
|
||||
var method = this.MethodInfos.GetType().GetMyMethod("ThenInclude", 2, isList)
|
||||
.MakeGenericMethod(properyItemType);
|
||||
var obj = method.Invoke(this.MethodInfos, new object[] { exp, updateNavOptions });
|
||||
var obj = method.Invoke(this.MethodInfos, new object[] { exp, insertNavOptions });
|
||||
this.MethodInfos = obj;
|
||||
return this;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user