mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 13:34:32 +08:00
-
This commit is contained in:
parent
63c0b56705
commit
a5a6eefe8c
Binary file not shown.
@ -36,7 +36,7 @@ namespace OrmTest.ExpressionTest
|
|||||||
}
|
}
|
||||||
private static void MultipleDynamic()
|
private static void MultipleDynamic()
|
||||||
{
|
{
|
||||||
Expression<Func<Student, School, object>> exp = (it, school) => new{ Name = "a", Id = it.Id, SchoolId = school.Id };
|
Expression<Func<Student, School, object>> exp = (it, school) => new{ Name = "a", Id = it.Id/2, SchoolId = school.Id };
|
||||||
ExpressionContext expContext = new ExpressionContext(exp, ResolveExpressType.SelectMultiple);
|
ExpressionContext expContext = new ExpressionContext(exp, ResolveExpressType.SelectMultiple);
|
||||||
expContext.Resolve();
|
expContext.Resolve();
|
||||||
var selectorValue = expContext.Result.GetString();
|
var selectorValue = expContext.Result.GetString();
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -17,5 +17,6 @@ namespace SqlSugar
|
|||||||
public object TempDate { get; set; }
|
public object TempDate { get; set; }
|
||||||
public ExpressionParameter BaseParameter { get; set; }
|
public ExpressionParameter BaseParameter { get; set; }
|
||||||
public int SwitchCaseNumber { get; set; }
|
public int SwitchCaseNumber { get; set; }
|
||||||
|
public bool IsOnlyAddTempDate { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,14 +81,14 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
switch (this._ResolveExpressType)
|
switch (this._ResolveExpressType)
|
||||||
{
|
{
|
||||||
|
case ResolveExpressType.SelectSingle:
|
||||||
|
case ResolveExpressType.SelectMultiple:
|
||||||
|
parameter = parameter + ",";
|
||||||
|
break;
|
||||||
case ResolveExpressType.WhereSingle:
|
case ResolveExpressType.WhereSingle:
|
||||||
break;
|
break;
|
||||||
case ResolveExpressType.WhereMultiple:
|
case ResolveExpressType.WhereMultiple:
|
||||||
break;
|
break;
|
||||||
case ResolveExpressType.SelectSingle:
|
|
||||||
break;
|
|
||||||
case ResolveExpressType.SelectMultiple:
|
|
||||||
break;
|
|
||||||
case ResolveExpressType.FieldSingle:
|
case ResolveExpressType.FieldSingle:
|
||||||
break;
|
break;
|
||||||
case ResolveExpressType.FieldMultiple:
|
case ResolveExpressType.FieldMultiple:
|
||||||
|
@ -8,6 +8,14 @@ namespace SqlSugar
|
|||||||
public class BinaryExpressionResolve : BaseResolve
|
public class BinaryExpressionResolve : BaseResolve
|
||||||
{
|
{
|
||||||
public BinaryExpressionResolve(ExpressionParameter parameter) : base(parameter)
|
public BinaryExpressionResolve(ExpressionParameter parameter) : base(parameter)
|
||||||
|
{
|
||||||
|
if (parameter.BaseParameter.TempDate != null && parameter.BaseParameter.TempDate.Equals("simple"))
|
||||||
|
{
|
||||||
|
parameter.IsOnlyAddTempDate = true;
|
||||||
|
new SimpleBinaryExpressionResolve(parameter);
|
||||||
|
parameter.IsOnlyAddTempDate = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
parameter.BinaryExpressionInfoList = new List<KeyValuePair<string, BinaryExpressionInfo>>();
|
parameter.BinaryExpressionInfoList = new List<KeyValuePair<string, BinaryExpressionInfo>>();
|
||||||
var expression = this.Expression as BinaryExpression;
|
var expression = this.Expression as BinaryExpression;
|
||||||
@ -42,6 +50,7 @@ namespace SqlSugar
|
|||||||
base.Context.Result.Replace(ExpressionConst.Format1, ExpressionConst.Format0);
|
base.Context.Result.Replace(ExpressionConst.Format1, ExpressionConst.Format0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private string GetRightString(ExpressionParameter parameter)
|
private string GetRightString(ExpressionParameter parameter)
|
||||||
{
|
{
|
||||||
|
@ -58,6 +58,9 @@ namespace SqlSugar
|
|||||||
base.Expression = memberAssignment.Expression;
|
base.Expression = memberAssignment.Expression;
|
||||||
base.Start();
|
base.Start();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Check.ThrowNotSupportedException(item.GetType().Name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,19 +49,21 @@ namespace SqlSugar
|
|||||||
parameter.Context.Result.Append(parameterName);
|
parameter.Context.Result.Append(parameterName);
|
||||||
this.Context.Parameters.Add(new SugarParameter(parameterName, parameter.TempDate));
|
this.Context.Parameters.Add(new SugarParameter(parameterName, parameter.TempDate));
|
||||||
}
|
}
|
||||||
else
|
else if (item is MemberExpression)
|
||||||
{
|
{
|
||||||
var memberExpression = (MemberExpression)item;
|
base.Expression = item;
|
||||||
var fieldNme = (memberExpression).Member.Name;
|
base.Start();
|
||||||
if (isSingle)
|
}
|
||||||
|
else if (item is BinaryExpression)
|
||||||
{
|
{
|
||||||
parameter.Context.Result.Append(fieldNme);
|
base.Expression = item;
|
||||||
|
parameter.TempDate = "simple";
|
||||||
|
base.Start();
|
||||||
|
parameter.TempDate =null;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var shortName = memberExpression.Expression.ToString();
|
Check.ThrowNotSupportedException(item.GetType().Name);
|
||||||
parameter.Context.Result.Append(shortName + "." + fieldNme);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
namespace SqlSugar
|
||||||
|
{
|
||||||
|
public class SimpleBinaryExpressionResolve : BaseResolve
|
||||||
|
{
|
||||||
|
public SimpleBinaryExpressionResolve(ExpressionParameter parameter) : base(parameter)
|
||||||
|
{
|
||||||
|
var expression = base.Expression as BinaryExpression;
|
||||||
|
switch (parameter.Context.ResolveType)
|
||||||
|
{
|
||||||
|
case ResolveExpressType.SelectSingle:
|
||||||
|
case ResolveExpressType.SelectMultiple:
|
||||||
|
|
||||||
|
base.Expression = expression.Right;
|
||||||
|
base.Start();
|
||||||
|
var rightValue = parameter.TempDate;
|
||||||
|
base.Expression = expression.Left;
|
||||||
|
base.Start();
|
||||||
|
var leftValue = parameter.TempDate;
|
||||||
|
break;
|
||||||
|
case ResolveExpressType.WhereSingle:
|
||||||
|
case ResolveExpressType.WhereMultiple:
|
||||||
|
case ResolveExpressType.FieldSingle:
|
||||||
|
case ResolveExpressType.FieldMultiple:
|
||||||
|
default:
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -126,6 +126,7 @@
|
|||||||
<Compile Include="ExpressionsToSql\ResolveItems\MemberExpressionResolve.cs" />
|
<Compile Include="ExpressionsToSql\ResolveItems\MemberExpressionResolve.cs" />
|
||||||
<Compile Include="ExpressionsToSql\ResolveItems\MethodCallExpressionResolve.cs" />
|
<Compile Include="ExpressionsToSql\ResolveItems\MethodCallExpressionResolve.cs" />
|
||||||
<Compile Include="ExpressionsToSql\ResolveItems\NewExpressionResolve.cs" />
|
<Compile Include="ExpressionsToSql\ResolveItems\NewExpressionResolve.cs" />
|
||||||
|
<Compile Include="ExpressionsToSql\ResolveItems\SimpleBinaryExpressionResolve.cs" />
|
||||||
<Compile Include="ExpressionsToSql\ResolveItems\UnaryExpressionResolve.cs" />
|
<Compile Include="ExpressionsToSql\ResolveItems\UnaryExpressionResolve.cs" />
|
||||||
<Compile Include="ExpressionsToSql\Common\ExpResolveAccessory.cs" />
|
<Compile Include="ExpressionsToSql\Common\ExpResolveAccessory.cs" />
|
||||||
<Compile Include="ExpressionsToSql\ExpressionContext.cs" />
|
<Compile Include="ExpressionsToSql\ExpressionContext.cs" />
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user