|
|
@ -11,23 +11,52 @@ namespace SqlSugar |
|
|
|
public SqlSugarProvider Context { get; internal set; } |
|
|
|
public Type EntityType { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
#region Json 2 sql api
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Sql API
|
|
|
|
public QueryMethodInfo AS(string tableName) |
|
|
|
{ |
|
|
|
string shortName = $"{tableName}_1"; |
|
|
|
var method = QueryableObj.GetType().GetMyMethod("AS", 2, typeof(string), typeof(string)); |
|
|
|
this.QueryableObj = method.Invoke(QueryableObj, new object[] { tableName, shortName }); |
|
|
|
return this; |
|
|
|
} |
|
|
|
public QueryMethodInfo AS(string tableName, string shortName) |
|
|
|
{ |
|
|
|
var method = QueryableObj.GetType().GetMyMethod("AS", 2, typeof(string), typeof(string)); |
|
|
|
this.QueryableObj = method.Invoke(QueryableObj, new object[] { tableName, shortName }); |
|
|
|
return this; |
|
|
|
} |
|
|
|
public QueryMethodInfo OrderBy(string orderBySql) |
|
|
|
{ |
|
|
|
var method = QueryableObj.GetType().GetMyMethod("OrderBy", 1, typeof(string)); |
|
|
|
this.QueryableObj = method.Invoke(QueryableObj, new object[] { orderBySql }); |
|
|
|
return this; |
|
|
|
} |
|
|
|
|
|
|
|
public QueryMethodInfo AddJoinInfo(string tableName, string shortName,string onWhere, 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,onWhere,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)); |
|
|
|
this.QueryableObj = method.Invoke(QueryableObj, new object[] { this.Context.EntityMaintenance.GetTableName(joinEntityType), shortName, onWhere, type }); |
|
|
|
return this; |
|
|
|
} |
|
|
|
public QueryMethodInfo GroupBy(string groupBySql) |
|
|
|
{ |
|
|
|
var method = QueryableObj.GetType().GetMyMethod("GroupBy", 1, typeof(string)); |
|
|
|
this.QueryableObj = method.Invoke(QueryableObj, new object[] { groupBySql }); |
|
|
|
return this; |
|
|
|
} |
|
|
|
public QueryMethodInfo Where(string sql, object parameters=null) |
|
|
|
public QueryMethodInfo Where(string sql, object parameters = null) |
|
|
|
{ |
|
|
|
var method = QueryableObj.GetType().GetMyMethod("Where", 2, typeof(string), typeof(object)); |
|
|
|
this.QueryableObj= method.Invoke(QueryableObj, new object[] { sql, parameters }); |
|
|
|
this.QueryableObj = method.Invoke(QueryableObj, new object[] { sql, parameters }); |
|
|
|
return this; |
|
|
|
} |
|
|
|
public QueryMethodInfo Having(string sql, object parameters = null) |
|
|
@ -39,13 +68,13 @@ namespace SqlSugar |
|
|
|
public QueryMethodInfo SplitTable(Func<List<SplitTableInfo>, IEnumerable<SplitTableInfo>> getTableNamesFunc) |
|
|
|
{ |
|
|
|
var method = QueryableObj.GetType().GetMyMethod("SplitTable", 1, typeof(Func<List<SplitTableInfo>, IEnumerable<SplitTableInfo>>)); |
|
|
|
this.QueryableObj = method.Invoke(QueryableObj, new object[] { getTableNamesFunc}); |
|
|
|
this.QueryableObj = method.Invoke(QueryableObj, new object[] { getTableNamesFunc }); |
|
|
|
return this; |
|
|
|
} |
|
|
|
public QueryMethodInfo SplitTable(DateTime begintTime,DateTime endTime) |
|
|
|
public QueryMethodInfo SplitTable(DateTime begintTime, DateTime endTime) |
|
|
|
{ |
|
|
|
var method = QueryableObj.GetType().GetMyMethod("SplitTable", 2, typeof(DateTime), typeof(DateTime)); |
|
|
|
this.QueryableObj = method.Invoke(QueryableObj, new object[] {begintTime,endTime }); |
|
|
|
this.QueryableObj = method.Invoke(QueryableObj, new object[] { begintTime, endTime }); |
|
|
|
return this; |
|
|
|
} |
|
|
|
public QueryMethodInfo SplitTable() |
|
|
@ -63,14 +92,16 @@ namespace SqlSugar |
|
|
|
return this; |
|
|
|
} |
|
|
|
|
|
|
|
public QueryMethodInfo Select(string selectorSql, Type selectType) |
|
|
|
public QueryMethodInfo Select(string selectorSql, Type selectType) |
|
|
|
{ |
|
|
|
var method = QueryableObj.GetType().GetMyMethod("Select", 1, typeof(string)) |
|
|
|
var method = QueryableObj.GetType().GetMyMethod("Select", 1, typeof(string)) |
|
|
|
.MakeGenericMethod(selectType); |
|
|
|
this.QueryableObj = method.Invoke(QueryableObj, new object[] { selectorSql }); |
|
|
|
return this; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Result
|
|
|
|
public object ToPageList(int pageNumber, int pageSize) |
|
|
|
{ |
|
|
|