Update db.QueryableByObject

This commit is contained in:
sunkaixuan 2023-06-15 19:56:27 +08:00
parent c984999d62
commit 31d98190ed
2 changed files with 26 additions and 0 deletions

View File

@ -65,10 +65,22 @@ namespace OrmTest
var whereFunc = ObjectFuncModel.Create("Format", "o.id", ">", "{int}:1", "&&", "o.name", "=", "{string}:a");
var data661 = db.Queryable<object>().AS("[order]", "o")
.AddJoinInfo("order", "y", "o.id=y.id", SqlSugar.JoinType.Left)
.Where(whereFunc)
.GroupBy(groupList).Having(having).Select(selector).ToList();
var data66 = db.QueryableByObject(type, "o")
.AddJoinInfo(typeof(Custom), "y", "o.id=y.id", SqlSugar.JoinType.Left)
.Where(whereFunc)
.GroupBy(groupList).Having(having).Select(selector).ToList();
var data67 = db.QueryableByObject(type, "o")
.AddJoinInfo("order", "y", ObjectFuncModel.Create("Equals", "y.id", "o.id"), SqlSugar.JoinType.Left)
.Where(whereFunc)
.GroupBy(groupList).Having(having).Select(selector).ToList();
}
}
}

View File

@ -50,6 +50,20 @@ namespace SqlSugar
this.QueryableObj = method.Invoke(QueryableObj, new object[] { tableName,shortName,onWhere,type });
return this;
}
public QueryMethodInfo AddJoinInfo(string tableName, string shortName, IFuncModel onFunc, JoinType type = JoinType.Left)
{
var method = QueryableObj.GetType().GetMyMethod("AddJoinInfo", 4, typeof(string), typeof(string), typeof(string), typeof(JoinType));
this.QueryableObj = method.Invoke(QueryableObj, new object[] { tableName, shortName, onFunc, type });
return this;
}
public QueryMethodInfo AddJoinInfo(List<JoinInfoParameter> joinInfoParameters)
{
foreach (var item in joinInfoParameters)
{
AddJoinInfo(item.TableName,item.ShortName,item.Models,item.Type);
}
return this;
}
public QueryMethodInfo AddJoinInfo(Type joinEntityType, string shortName, string onWhere, JoinType type = JoinType.Left)
{
var method = QueryableObj.GetType().GetMyMethod("AddJoinInfo", 4, typeof(string), typeof(string), typeof(string), typeof(JoinType));