Synchronization code

This commit is contained in:
sunkaixuan
2022-11-10 17:16:47 +08:00
parent 21408f4598
commit 8e5dfe706c
3 changed files with 20 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ using System.Text.RegularExpressions;
using System.Reflection;
using System.Dynamic;
using System.Threading.Tasks;
using Newtonsoft.Json.Serialization;
namespace SqlSugar
{
@@ -389,6 +390,23 @@ namespace SqlSugar
InitMapping();
return _ToList<T>();
}
public List<T> SetContext<ParameterT>(Expression<Func<T, bool>> whereExpression, ParameterT parameter)
{
var queryableContext = this.Context.TempItems["Queryable_To_Context"] as MapperContext<ParameterT>;
var rootList = queryableContext.list;
List<ISugarQueryable<object>> queryableList = new List<ISugarQueryable<object>>();
var index = rootList.IndexOf(parameter);
var selector = this.Clone().QueryBuilder.GetSelectValue+$",{index} as ";
var sqlObj=this.Clone().Where(whereExpression).Select(selector+"")
.Select(it => (object) new { it, sql_sugar_index = index });
queryableList.Add(sqlObj);
var allList = this.Context.Union(queryableList)
.Select(it=>new { it=default(T), sql_sugar_index =0})
.Select("*").ToList();
var result = new List<T>();
throw new Exception("开发中");
}
public List<T> SetContext<ParameterT>(Expression<Func<T, object>> thisFiled, Expression<Func<object>> mappingFiled, ParameterT parameter)
{
if (parameter == null)

View File

@@ -153,6 +153,7 @@ namespace SqlSugar
List<TResult> ToList<TResult>(Expression<Func<T, TResult>> expression);
Task<List<TResult>> ToListAsync<TResult>(Expression<Func<T, TResult>> expression);
List<T> ToList();
List<T> SetContext<ParameterT>(Expression<Func<T, bool>> whereExpression, ParameterT parameter);
List<T> SetContext<ParameterT>(Expression<Func<T,object>> thisFiled, Expression<Func<object>> mappingFiled, ParameterT parameter);
List<T> SetContext<ParameterT>(Expression<Func<T, object>> thisFiled1, Expression<Func<object>> mappingFiled1, Expression<Func<T, object>> thisFiled2, Expression<Func<object>> mappingFiled2, ParameterT parameter);
Task <List<T>> SetContextAsync<ParameterT>(Expression<Func<T, object>> thisFiled, Expression<Func<object>> mappingFiled, ParameterT parameter);

View File

@@ -58,7 +58,7 @@ namespace SqlSugar
this.OrderByValue = null;
}
if (this.OrderByValue == "ORDER BY ") this.OrderByValue += GetSelectValue.Split(',')[0];
result = string.Format(PageTempalte, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, GetOrderByString, Skip.ObjToInt() > 0 ? Skip.ObjToInt() : 0, Take);
result = string.Format(PageTempalte, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, GetOrderByString, Skip.ObjToInt() > 0 ? Skip.ObjToInt() : 0, Skip+Take);
}
else
{