mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-22 20:13:41 +08:00
queryable.IncludesByNameString(+5)
This commit is contained in:
@@ -21,6 +21,16 @@ namespace SqlSugar
|
|||||||
_Includes<T, TReturn1, TReturn2, TReturn3>(this.Context, include1, include2, include3);
|
_Includes<T, TReturn1, TReturn2, TReturn3>(this.Context, include1, include2, include3);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
public ISugarQueryable<T> IncludesByExpression4<TReturn1, TReturn2, TReturn3, TReturn4>(Expression include1, Expression include2, Expression include3, Expression include4)
|
||||||
|
{
|
||||||
|
_Includes<T, TReturn1, TReturn2, TReturn3, TReturn4>(this.Context, include1, include2, include3, include4);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public ISugarQueryable<T> IncludesByExpression5<TReturn1, TReturn2, TReturn3, TReturn4, TReturn5>(Expression include1, Expression include2, Expression include3, Expression include4, Expression include5)
|
||||||
|
{
|
||||||
|
_Includes<T, TReturn1, TReturn2, TReturn3, TReturn4, TReturn5>(this.Context, include1, include2, include3, include4, include5);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
public ISugarQueryable<T> IncludesByExpression<TReturn1>(Expression include1)
|
public ISugarQueryable<T> IncludesByExpression<TReturn1>(Expression include1)
|
||||||
{
|
{
|
||||||
_Includes<T, TReturn1>(this.Context, include1);
|
_Includes<T, TReturn1>(this.Context, include1);
|
||||||
@@ -56,7 +66,44 @@ namespace SqlSugar
|
|||||||
method.MakeGenericMethod(types.ToArray()).Invoke(this, parametres.Cast<object>().ToArray());
|
method.MakeGenericMethod(types.ToArray()).Invoke(this, parametres.Cast<object>().ToArray());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
public ISugarQueryable<T> IncludesByNameString(string navMemberName, string thenNavMemberName2, string thenNavMemberName3, string thenNavMemberName4)
|
||||||
|
{
|
||||||
|
var method = this.GetType().GetMethods().Where(it => it.Name == "IncludesByExpression4")
|
||||||
|
.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);
|
||||||
|
var entityInfo4 = this.Context.EntityMaintenance.GetEntityInfo(types.Last());
|
||||||
|
method = GetIncludesByNameStringMethod(types, thenNavMemberName4, method, parametres, entityInfo4);
|
||||||
|
method.MakeGenericMethod(types.ToArray()).Invoke(this, parametres.Cast<object>().ToArray());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public ISugarQueryable<T> IncludesByNameString(string navMemberName, string thenNavMemberName2, string thenNavMemberName3, string thenNavMemberName4, string thenNavMemberName5)
|
||||||
|
{
|
||||||
|
var method = this.GetType().GetMethods().Where(it => it.Name == "IncludesByExpression5")
|
||||||
|
.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);
|
||||||
|
var entityInfo4 = this.Context.EntityMaintenance.GetEntityInfo(types.Last());
|
||||||
|
method = GetIncludesByNameStringMethod(types, thenNavMemberName4, method, parametres, entityInfo4);
|
||||||
|
var entityInfo5 = this.Context.EntityMaintenance.GetEntityInfo(types.Last());
|
||||||
|
method = GetIncludesByNameStringMethod(types, thenNavMemberName5, method, parametres, entityInfo5);
|
||||||
|
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)
|
private static MethodInfo GetIncludesByNameStringMethod(List<Type> types,string navMemberName, MethodInfo method, List<Expression> parametres, EntityInfo entityInfo)
|
||||||
{
|
{
|
||||||
var navFirst = GetNavColumnInfo(navMemberName, entityInfo);
|
var navFirst = GetNavColumnInfo(navMemberName, entityInfo);
|
||||||
|
@@ -51,6 +51,44 @@ namespace SqlSugar
|
|||||||
if (this.QueryBuilder.Includes == null) this.QueryBuilder.Includes = new List<object>();
|
if (this.QueryBuilder.Includes == null) this.QueryBuilder.Includes = new List<object>();
|
||||||
this.QueryBuilder.Includes.Add(navigat);
|
this.QueryBuilder.Includes.Add(navigat);
|
||||||
}
|
}
|
||||||
|
private void _Includes<T1, TReturn1, TReturn2, TReturn3, TReturn4>(SqlSugarProvider context, params Expression[] expressions)
|
||||||
|
{
|
||||||
|
Func<ISugarQueryable<object>, List<object>> SelectR1 = it => it.Select<TReturn1>().ToList().Select(x => x as object).ToList();
|
||||||
|
Func<ISugarQueryable<object>, List<object>> SelectR2 = it => it.Select<TReturn2>().ToList().Select(x => x as object).ToList();
|
||||||
|
Func<ISugarQueryable<object>, List<object>> SelectR3 = it => it.Select<TReturn3>().ToList().Select(x => x as object).ToList();
|
||||||
|
Func<ISugarQueryable<object>, List<object>> SelectR4 = it => it.Select<TReturn4>().ToList().Select(x => x as object).ToList();
|
||||||
|
var navigat = new NavigatManager<T>();
|
||||||
|
navigat.SelectR1 = SelectR1;
|
||||||
|
navigat.SelectR2 = SelectR2;
|
||||||
|
navigat.SelectR3 = SelectR3;
|
||||||
|
navigat.SelectR4 = SelectR4;
|
||||||
|
navigat.Expressions = expressions;
|
||||||
|
navigat.IsCrossQueryWithAttr = this.QueryBuilder.IsCrossQueryWithAttr;
|
||||||
|
navigat.CrossQueryItems = this.QueryBuilder.CrossQueryItems;
|
||||||
|
navigat.Context = this.Context;
|
||||||
|
if (this.QueryBuilder.Includes == null) this.QueryBuilder.Includes = new List<object>();
|
||||||
|
this.QueryBuilder.Includes.Add(navigat);
|
||||||
|
}
|
||||||
|
private void _Includes<T1, TReturn1, TReturn2, TReturn3, TReturn4, TReturn5>(SqlSugarProvider context, params Expression[] expressions)
|
||||||
|
{
|
||||||
|
Func<ISugarQueryable<object>, List<object>> SelectR1 = it => it.Select<TReturn1>().ToList().Select(x => x as object).ToList();
|
||||||
|
Func<ISugarQueryable<object>, List<object>> SelectR2 = it => it.Select<TReturn2>().ToList().Select(x => x as object).ToList();
|
||||||
|
Func<ISugarQueryable<object>, List<object>> SelectR3 = it => it.Select<TReturn3>().ToList().Select(x => x as object).ToList();
|
||||||
|
Func<ISugarQueryable<object>, List<object>> SelectR4 = it => it.Select<TReturn4>().ToList().Select(x => x as object).ToList();
|
||||||
|
Func<ISugarQueryable<object>, List<object>> SelectR5 = it => it.Select<TReturn5>().ToList().Select(x => x as object).ToList();
|
||||||
|
var navigat = new NavigatManager<T>();
|
||||||
|
navigat.SelectR1 = SelectR1;
|
||||||
|
navigat.SelectR2 = SelectR2;
|
||||||
|
navigat.SelectR3 = SelectR3;
|
||||||
|
navigat.SelectR4 = SelectR4;
|
||||||
|
navigat.SelectR5 = SelectR5;
|
||||||
|
navigat.Expressions = expressions;
|
||||||
|
navigat.IsCrossQueryWithAttr = this.QueryBuilder.IsCrossQueryWithAttr;
|
||||||
|
navigat.CrossQueryItems = this.QueryBuilder.CrossQueryItems;
|
||||||
|
navigat.Context = this.Context;
|
||||||
|
if (this.QueryBuilder.Includes == null) this.QueryBuilder.Includes = new List<object>();
|
||||||
|
this.QueryBuilder.Includes.Add(navigat);
|
||||||
|
}
|
||||||
public NavISugarQueryable<T> AsNavQueryable()
|
public NavISugarQueryable<T> AsNavQueryable()
|
||||||
{
|
{
|
||||||
return GetNavSugarQueryable();
|
return GetNavSugarQueryable();
|
||||||
|
@@ -19,6 +19,8 @@ namespace SqlSugar
|
|||||||
ISugarQueryable<T> IncludesByNameString(string navMemberName);
|
ISugarQueryable<T> IncludesByNameString(string navMemberName);
|
||||||
ISugarQueryable<T> IncludesByNameString(string navMemberName,string thenNavMemberName2);
|
ISugarQueryable<T> IncludesByNameString(string navMemberName,string thenNavMemberName2);
|
||||||
ISugarQueryable<T> IncludesByNameString(string navMemberName, string thenNavMemberName2, string thenNavMemberName3);
|
ISugarQueryable<T> IncludesByNameString(string navMemberName, string thenNavMemberName2, string thenNavMemberName3);
|
||||||
|
ISugarQueryable<T> IncludesByNameString(string navMemberName, string thenNavMemberName2, string thenNavMemberName3, string thenNavMemberName4);
|
||||||
|
ISugarQueryable<T> IncludesByNameString(string navMemberName, string thenNavMemberName2, string thenNavMemberName3, string thenNavMemberName4,string thenNavMemberName5);
|
||||||
ISugarQueryable<T> IncludesAllFirstLayer(params string[] ignoreProperyNameList);
|
ISugarQueryable<T> IncludesAllFirstLayer(params string[] ignoreProperyNameList);
|
||||||
ISugarQueryable<T> IncludesAllSecondLayer<TReturn1>(Expression<Func<T, TReturn1>> expression,params string[] ignoreProperyNameList);
|
ISugarQueryable<T> IncludesAllSecondLayer<TReturn1>(Expression<Func<T, TReturn1>> expression,params string[] ignoreProperyNameList);
|
||||||
ISugarQueryable<T> Includes<TReturn1>(Expression<Func<T, List<TReturn1>>> include1);
|
ISugarQueryable<T> Includes<TReturn1>(Expression<Func<T, List<TReturn1>>> include1);
|
||||||
|
Reference in New Issue
Block a user