Updat db.QueryableByObject

This commit is contained in:
sunkaixuan
2023-06-18 18:58:45 +08:00
parent 937fd43524
commit 5e7acb4a37
2 changed files with 27 additions and 0 deletions

View File

@@ -16,6 +16,11 @@ namespace SqlSugar
_Includes<T, TReturn1,TReturn2>(this.Context, include1,include2);
return this;
}
public ISugarQueryable<T> IncludesByExpression3<TReturn1, TReturn2, TReturn3>(Expression include1, Expression include2, Expression include3)
{
_Includes<T, TReturn1, TReturn2, TReturn3>(this.Context, include1, include2, include3);
return this;
}
public ISugarQueryable<T> IncludesByExpression<TReturn1>(Expression include1)
{
_Includes<T, TReturn1>(this.Context, include1);
@@ -35,6 +40,22 @@ namespace SqlSugar
method.MakeGenericMethod(types.ToArray()).Invoke(this, parametres.Cast<object>().ToArray());
return this;
}
public ISugarQueryable<T> IncludesByNameString(string navMemberName, string thenNavMemberName2,string thenNavMemberName3)
{
var method = this.GetType().GetMethods().Where(it => it.Name == "IncludesByExpression3")
.First();
List<Expression> parametres = new List<Expression>();
List<Type> types = new List<Type>();
var entityInfo = this.EntityInfo;
method = GetIncludesByNameStringMethod(types, navMemberName, method, parametres, entityInfo);
//var navFirst = GetNavColumnInfo(navMemberName, entityInfo);
var entityInfo2 = this.Context.EntityMaintenance.GetEntityInfo(types.Last());
method = GetIncludesByNameStringMethod(types, thenNavMemberName2, method, parametres, entityInfo2);
var entityInfo3 = this.Context.EntityMaintenance.GetEntityInfo(types.Last());
method = GetIncludesByNameStringMethod(types, thenNavMemberName3, method, parametres, entityInfo3);
method.MakeGenericMethod(types.ToArray()).Invoke(this, parametres.Cast<object>().ToArray());
return this;
}
private static MethodInfo GetIncludesByNameStringMethod(List<Type> types,string navMemberName, MethodInfo method, List<Expression> parametres, EntityInfo entityInfo)
{

View File

@@ -184,6 +184,12 @@ namespace SqlSugar
this.QueryableObj = method.Invoke(QueryableObj, new object[] { navProperyName , thenNavProperyName2 });
return this;
}
public QueryMethodInfo Includes(string navProperyName, string thenNavProperyName2, string thenNavProperyName3)
{
var method = QueryableObj.GetType().GetMyMethod("IncludesByNameString", 3, typeof(string), typeof(string),typeof(string));
this.QueryableObj = method.Invoke(QueryableObj, new object[] { navProperyName, thenNavProperyName2 , thenNavProperyName3 });
return this;
}
#endregion
#region Result