mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-01 10:10:16 +08:00
Add SetContext(exp)
This commit is contained in:
parent
dbaaa80902
commit
eb4d5152e3
@ -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,24 @@ 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("开发中");
|
||||
return result;
|
||||
}
|
||||
public List<T> SetContext<ParameterT>(Expression<Func<T, object>> thisFiled, Expression<Func<object>> mappingFiled, ParameterT parameter)
|
||||
{
|
||||
if (parameter == null)
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user