mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-15 18:55:07 +08:00
-
This commit is contained in:
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.
Binary file not shown.
@@ -8,15 +8,14 @@ namespace SqlSugar
|
||||
{
|
||||
public class ExpressionParameter
|
||||
{
|
||||
public Expression Expression { get; set; }
|
||||
public ExpressionContext Context { get; set; }
|
||||
public bool? IsLeft { get; set; }
|
||||
public Expression BaseExpression { get; set; }
|
||||
public int Index { get; set; }
|
||||
public List<KeyValuePair<string, BinaryExpressionInfo>> BinaryExpressionInfoList { get; set; }
|
||||
public object TempDate { get; set; }
|
||||
public ExpressionParameter BaseParameter { get; set; }
|
||||
public int SwitchCaseNumber { get; set; }
|
||||
public bool IsOnlyAddTempDate { get; set; }
|
||||
public Expression BaseExpression { get; set; }
|
||||
public Expression Expression { get; set; }
|
||||
public bool? IsLeft { get; set; }
|
||||
public int Index { get; set; }
|
||||
public object CommonTempData { get; set; }
|
||||
public List<KeyValuePair<string, BinaryExpressionInfo>> BinaryTempData { get; set; }
|
||||
public ExpressionResultAppendType AppendType { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -7,6 +7,7 @@ namespace SqlSugar
|
||||
{
|
||||
public class ExpressionResult
|
||||
{
|
||||
public ExpressionParameter CurrentParameter { get; set; }
|
||||
#region constructor
|
||||
private ExpressionResult()
|
||||
{
|
||||
@@ -57,6 +58,10 @@ namespace SqlSugar
|
||||
|
||||
public void Append(object parameter)
|
||||
{
|
||||
if (this.CurrentParameter.IsValuable() && this.CurrentParameter.AppendType.IsIn(ExpressionResultAppendType.AppendTempDate)) {
|
||||
this.CurrentParameter.CommonTempData = parameter;
|
||||
return;
|
||||
}
|
||||
switch (this._ResolveExpressType)
|
||||
{
|
||||
case ResolveExpressType.SelectSingle:
|
||||
@@ -79,6 +84,11 @@ namespace SqlSugar
|
||||
|
||||
public void AppendFormat(string parameter, params object[] orgs)
|
||||
{
|
||||
if (this.CurrentParameter.IsValuable() && this.CurrentParameter.AppendType.IsIn(ExpressionResultAppendType.AppendTempDate))
|
||||
{
|
||||
this.CurrentParameter.CommonTempData = new KeyValuePair<string,object[]>(parameter,orgs);
|
||||
return;
|
||||
}
|
||||
switch (this._ResolveExpressType)
|
||||
{
|
||||
case ResolveExpressType.SelectSingle:
|
||||
|
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
public enum ExpressionResultAppendType
|
||||
{
|
||||
AppendResult=0,
|
||||
AppendTempDate=1
|
||||
}
|
||||
}
|
@@ -9,15 +9,17 @@ namespace SqlSugar
|
||||
{
|
||||
public BinaryExpressionResolve(ExpressionParameter parameter) : base(parameter)
|
||||
{
|
||||
if (parameter.BaseParameter.TempDate != null && parameter.BaseParameter.TempDate.Equals("simple"))
|
||||
if (parameter.BaseParameter.CommonTempData != null && parameter.BaseParameter.CommonTempData.Equals("simple"))
|
||||
{
|
||||
parameter.IsOnlyAddTempDate = true;
|
||||
parameter.BaseParameter = parameter;
|
||||
parameter.AppendType = ExpressionResultAppendType.AppendTempDate;
|
||||
this.Context.Result.CurrentParameter = parameter;
|
||||
new SimpleBinaryExpressionResolve(parameter);
|
||||
parameter.IsOnlyAddTempDate = false;
|
||||
this.Context.Result.CurrentParameter = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
parameter.BinaryExpressionInfoList = new List<KeyValuePair<string, BinaryExpressionInfo>>();
|
||||
parameter.BinaryTempData = new List<KeyValuePair<string, BinaryExpressionInfo>>();
|
||||
var expression = this.Expression as BinaryExpression;
|
||||
var operatorValue = ExpressionTool.GetOperator(expression.NodeType);
|
||||
var isComparisonOperator =
|
||||
@@ -54,8 +56,8 @@ namespace SqlSugar
|
||||
|
||||
private string GetRightString(ExpressionParameter parameter)
|
||||
{
|
||||
var leftInfo = parameter.BinaryExpressionInfoList.Single(it => it.Value.IsLeft).Value;
|
||||
var rightInfo = parameter.BinaryExpressionInfoList.Single(it => !it.Value.IsLeft).Value;
|
||||
var leftInfo = parameter.BinaryTempData.Single(it => it.Value.IsLeft).Value;
|
||||
var rightInfo = parameter.BinaryTempData.Single(it => !it.Value.IsLeft).Value;
|
||||
if (rightInfo.ExpressionType == ExpressionConst.ConstantExpressionType)
|
||||
{
|
||||
var sqlParameterKeyWord = parameter.Context.SqlParameterKeyWord;
|
||||
@@ -71,8 +73,8 @@ namespace SqlSugar
|
||||
|
||||
private string GetLeftString(ExpressionParameter parameter)
|
||||
{
|
||||
var leftInfo = parameter.BinaryExpressionInfoList.Single(it => it.Value.IsLeft).Value;
|
||||
var rightInfo = parameter.BinaryExpressionInfoList.Single(it => !it.Value.IsLeft).Value;
|
||||
var leftInfo = parameter.BinaryTempData.Single(it => it.Value.IsLeft).Value;
|
||||
var rightInfo = parameter.BinaryTempData.Single(it => !it.Value.IsLeft).Value;
|
||||
if (leftInfo.ExpressionType == ExpressionConst.ConstantExpressionType)
|
||||
{
|
||||
var sqlParameterKeyWord = parameter.Context.SqlParameterKeyWord;
|
||||
|
@@ -17,16 +17,16 @@ namespace SqlSugar
|
||||
{
|
||||
case ResolveExpressType.SelectSingle:
|
||||
case ResolveExpressType.SelectMultiple:
|
||||
parameter.BaseParameter.TempDate = value;
|
||||
parameter.BaseParameter.CommonTempData = value;
|
||||
break;
|
||||
case ResolveExpressType.WhereSingle:
|
||||
case ResolveExpressType.WhereMultiple:
|
||||
case ResolveExpressType.FieldSingle:
|
||||
case ResolveExpressType.FieldMultiple:
|
||||
default:
|
||||
if (parameter.BaseParameter.BinaryExpressionInfoList != null)
|
||||
if (parameter.BaseParameter.BinaryTempData != null)
|
||||
{
|
||||
parameter.BaseParameter.BinaryExpressionInfoList.Add(new KeyValuePair<string, BinaryExpressionInfo>(ExpressionConst.BinaryExpressionInfoListKey, new BinaryExpressionInfo()
|
||||
parameter.BaseParameter.BinaryTempData.Add(new KeyValuePair<string, BinaryExpressionInfo>(ExpressionConst.BinaryExpressionInfoListKey, new BinaryExpressionInfo()
|
||||
{
|
||||
IsLeft = Convert.ToBoolean(isLeft),
|
||||
Value = value,
|
||||
|
@@ -18,16 +18,16 @@ namespace SqlSugar
|
||||
{
|
||||
case ResolveExpressType.SelectSingle:
|
||||
case ResolveExpressType.SelectMultiple:
|
||||
parameter.BaseParameter.TempDate = value;
|
||||
parameter.BaseParameter.CommonTempData = value;
|
||||
break;
|
||||
case ResolveExpressType.WhereSingle:
|
||||
case ResolveExpressType.WhereMultiple:
|
||||
case ResolveExpressType.FieldSingle:
|
||||
case ResolveExpressType.FieldMultiple:
|
||||
default:
|
||||
if (parameter.BaseParameter.BinaryExpressionInfoList != null)
|
||||
if (parameter.BaseParameter.BinaryTempData != null)
|
||||
{
|
||||
parameter.BaseParameter.BinaryExpressionInfoList.Add(new KeyValuePair<string, BinaryExpressionInfo>(ExpressionConst.BinaryExpressionInfoListKey, new BinaryExpressionInfo()
|
||||
parameter.BaseParameter.BinaryTempData.Add(new KeyValuePair<string, BinaryExpressionInfo>(ExpressionConst.BinaryExpressionInfoListKey, new BinaryExpressionInfo()
|
||||
{
|
||||
IsLeft = Convert.ToBoolean(isLeft),
|
||||
Value = value,
|
||||
|
@@ -7,6 +7,7 @@ namespace SqlSugar
|
||||
{
|
||||
public class MemberExpressionResolve : BaseResolve
|
||||
{
|
||||
public ExpressionParameter Parameter { get; set; }
|
||||
public MemberExpressionResolve(ExpressionParameter parameter) : base(parameter)
|
||||
{
|
||||
var expression = base.Expression as MemberExpression;
|
||||
@@ -48,8 +49,8 @@ namespace SqlSugar
|
||||
string shortName = expression.Expression.ToString();
|
||||
string fieldName = expression.Member.Name;
|
||||
fieldName = shortName + "." + fieldName;
|
||||
if (parameter.BaseParameter.BinaryExpressionInfoList != null)
|
||||
parameter.BaseParameter.BinaryExpressionInfoList.Add(new KeyValuePair<string, BinaryExpressionInfo>(ExpressionConst.BinaryExpressionInfoListKey, new BinaryExpressionInfo()
|
||||
if (parameter.BaseParameter.BinaryTempData != null)
|
||||
parameter.BaseParameter.BinaryTempData.Add(new KeyValuePair<string, BinaryExpressionInfo>(ExpressionConst.BinaryExpressionInfoListKey, new BinaryExpressionInfo()
|
||||
{
|
||||
IsLeft = Convert.ToBoolean(isLeft),
|
||||
Value = fieldName,
|
||||
@@ -61,8 +62,8 @@ namespace SqlSugar
|
||||
private string getSingleName(ExpressionParameter parameter, MemberExpression expression, bool? isLeft)
|
||||
{
|
||||
string fieldName = expression.Member.Name;
|
||||
if (parameter.BaseParameter.BinaryExpressionInfoList != null)
|
||||
parameter.BaseParameter.BinaryExpressionInfoList.Add(new KeyValuePair<string, BinaryExpressionInfo>(ExpressionConst.BinaryExpressionInfoListKey, new BinaryExpressionInfo()
|
||||
if (parameter.BaseParameter.BinaryTempData != null)
|
||||
parameter.BaseParameter.BinaryTempData.Add(new KeyValuePair<string, BinaryExpressionInfo>(ExpressionConst.BinaryExpressionInfoListKey, new BinaryExpressionInfo()
|
||||
{
|
||||
IsLeft = Convert.ToBoolean(isLeft),
|
||||
Value = fieldName,
|
||||
|
@@ -51,7 +51,7 @@ namespace SqlSugar
|
||||
base.Start();
|
||||
string parameterName = this.Context.SqlParameterKeyWord + "constant" + i;
|
||||
parameter.Context.Result.Append(parameterName);
|
||||
this.Context.Parameters.Add(new SugarParameter(parameterName, parameter.TempDate));
|
||||
this.Context.Parameters.Add(new SugarParameter(parameterName, parameter.CommonTempData));
|
||||
}
|
||||
else if (item is MemberExpression)
|
||||
{
|
||||
|
@@ -14,9 +14,9 @@ namespace SqlSugar
|
||||
var isLeft = parameter.IsLeft;
|
||||
object value = null;
|
||||
value = ExpressionTool.DynamicInvoke(expression);
|
||||
if (parameter.BaseParameter.BinaryExpressionInfoList != null)
|
||||
if (parameter.BaseParameter.BinaryTempData != null)
|
||||
{
|
||||
parameter.BaseParameter.BinaryExpressionInfoList.Add(new KeyValuePair<string, BinaryExpressionInfo>(ExpressionConst.BinaryExpressionInfoListKey, new BinaryExpressionInfo()
|
||||
parameter.BaseParameter.BinaryTempData.Add(new KeyValuePair<string, BinaryExpressionInfo>(ExpressionConst.BinaryExpressionInfoListKey, new BinaryExpressionInfo()
|
||||
{
|
||||
IsLeft = Convert.ToBoolean(isLeft),
|
||||
Value = value,
|
||||
|
@@ -23,9 +23,9 @@ namespace SqlSugar
|
||||
{
|
||||
value = ExpressionTool.GetPropertyValue(expression);
|
||||
}
|
||||
if (parameter.BaseParameter.BinaryExpressionInfoList != null)
|
||||
if (parameter.BaseParameter.BinaryTempData != null)
|
||||
{
|
||||
parameter.BaseParameter.BinaryExpressionInfoList.Add(new KeyValuePair<string, BinaryExpressionInfo>(ExpressionConst.BinaryExpressionInfoListKey, new BinaryExpressionInfo()
|
||||
parameter.BaseParameter.BinaryTempData.Add(new KeyValuePair<string, BinaryExpressionInfo>(ExpressionConst.BinaryExpressionInfoListKey, new BinaryExpressionInfo()
|
||||
{
|
||||
IsLeft = Convert.ToBoolean(isLeft),
|
||||
Value = value,
|
||||
|
@@ -47,7 +47,7 @@ namespace SqlSugar
|
||||
base.Start();
|
||||
string parameterName = this.Context.SqlParameterKeyWord + "constant" + i;
|
||||
parameter.Context.Result.Append(parameterName);
|
||||
this.Context.Parameters.Add(new SugarParameter(parameterName, parameter.TempDate));
|
||||
this.Context.Parameters.Add(new SugarParameter(parameterName, parameter.CommonTempData));
|
||||
}
|
||||
else if (item is MemberExpression)
|
||||
{
|
||||
@@ -57,9 +57,9 @@ namespace SqlSugar
|
||||
else if (item is BinaryExpression)
|
||||
{
|
||||
base.Expression = item;
|
||||
parameter.TempDate = "simple";
|
||||
parameter.CommonTempData = "simple";
|
||||
base.Start();
|
||||
parameter.TempDate =null;
|
||||
parameter.CommonTempData =null;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -18,10 +18,13 @@ namespace SqlSugar
|
||||
|
||||
base.Expression = expression.Right;
|
||||
base.Start();
|
||||
var rightValue = parameter.TempDate;
|
||||
var rightValue = parameter.CommonTempData;
|
||||
base.Expression = expression.Left;
|
||||
base.Start();
|
||||
var leftValue = parameter.TempDate;
|
||||
var leftValue = parameter.CommonTempData;
|
||||
var operatorValue = ExpressionTool.GetOperator(expression.NodeType);
|
||||
this.Context.Result.CurrentParameter = null;
|
||||
this.Context.Result.AppendFormat(ExpressionConst.BinaryFormatString, leftValue, operatorValue, rightValue);
|
||||
break;
|
||||
case ResolveExpressType.WhereSingle:
|
||||
case ResolveExpressType.WhereMultiple:
|
||||
|
@@ -100,6 +100,7 @@
|
||||
<Compile Include="ExpressionsToSql\Common\BinaryExpressionInfo.cs" />
|
||||
<Compile Include="ExpressionsToSql\Common\ExpressionResult.cs" />
|
||||
<Compile Include="ExpressionsToSql\Common\ExpressionErrorMessage.cs" />
|
||||
<Compile Include="ExpressionsToSql\Common\ExpressionResultAcceptType.cs" />
|
||||
<Compile Include="ExpressionsToSql\IDbMethods.cs" />
|
||||
<Compile Include="ExpressionsToSql\ResolveItems\MemberConstExpressionResolve.cs" />
|
||||
<Compile Include="ExpressionsToSql\ResolveItems\MemberInitExpressionResolve.cs" />
|
||||
|
Binary file not shown.
Binary file not shown.
@@ -3,4 +3,3 @@ F:\MyOpenSource\SqlSugar4.XNew\SqlSugar\SqlSugar\bin\Debug\SqlSugar.pdb
|
||||
F:\MyOpenSource\SqlSugar4.XNew\SqlSugar\SqlSugar\bin\Debug\Newtonsoft.Json.dll
|
||||
F:\MyOpenSource\SqlSugar4.XNew\SqlSugar\SqlSugar\obj\Debug\SqlSugar.dll
|
||||
F:\MyOpenSource\SqlSugar4.XNew\SqlSugar\SqlSugar\obj\Debug\SqlSugar.pdb
|
||||
F:\MyOpenSource\SqlSugar4.XNew\SqlSugar\SqlSugar\obj\Debug\SqlSugar.csprojResolveAssemblyReference.cache
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user