This commit is contained in:
sunkaixuan 2017-01-08 01:59:37 +08:00
parent 7697144d6d
commit 9f294b0b11
20 changed files with 41 additions and 30 deletions

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.

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public class BinaryExpressionInfo
{
public bool IsLeft { get; set; }
ExpressionType ExpressionType { get;set;}
public object Value { get; set; }
}
}

View File

@ -5,7 +5,15 @@ using System.Text;
namespace SqlSugar
{
internal class ExpConst
{
public const string FiledName = "filedName";
public const string FiledValue = "FiledValue";
public const string Operator = "Operator";
}
internal partial class ErrorMessage
{
internal static string OperatorError
{
@ -23,6 +31,6 @@ namespace SqlSugar
"表达示格式错误,正确格式: it=>it.fieldName");
}
}
}
}

View File

@ -13,6 +13,7 @@ namespace SqlSugar
public bool? IsLeft { get; set; }
public Expression BaseExpression { get; set; }
public int Index { get; set; }
public Dictionary<string, string> TempData { get; set; }
public Dictionary<string, object> TempData { get; set; }
public ExpressionParameter BaseParameter { get; set; }
}
}

View File

@ -11,7 +11,6 @@ namespace SqlSugar
protected Expression BaseExpression { get; set; }
public ExpressionContext Context { get; set; }
public string SqlWhere { get; set; }
public bool IsFinished { get; set; }
public bool? IsLeft { get; set; }
public int ContentIndex { get { return this.Context.Index; } }
public int Index { get; set; }
@ -25,12 +24,12 @@ namespace SqlSugar
{
this.Expression = parameter.Expression;
this.Context = parameter.Context;
this.BaseParameter = parameter;
}
public BaseResolve Start()
{
this.Index++;
this.IsFinished = false;
Expression exp = this.Expression;
ExpressionParameter parameter = new ExpressionParameter()
{
@ -38,6 +37,7 @@ namespace SqlSugar
Expression = exp,
IsLeft = this.IsLeft,
BaseExpression = this.BaseExpression,
BaseParameter=this.BaseParameter,
Index = this.Index
};
if (exp is LambdaExpression)
@ -78,12 +78,5 @@ namespace SqlSugar
}
return null;
}
public void Continue()
{
if (!IsFinished)
{
this.Start();
}
}
}
}

View File

@ -9,9 +9,10 @@ namespace SqlSugar
{
public BinaryExpressionResolve(ExpressionParameter parameter) : base(parameter)
{
parameter.TempData = new Dictionary<string, object>();
var expression = this.Expression as BinaryExpression;
parameter.TempData.Add(ExpConst.Operator, ExpTool.GetOperator(expression.NodeType));
base.BaseExpression = expression;
base.BaseParameter = parameter;
base.IsLeft = true;
base.Expression = expression.Left;
base.Start();
@ -19,7 +20,6 @@ namespace SqlSugar
base.Expression = expression.Right;
base.Start();
base.IsLeft = null;
base.Continue();
}
}
}

View File

@ -14,10 +14,12 @@ namespace SqlSugar
if (expression.NodeType == ExpressionType.MemberAccess)
{
base.SqlWhere = "(" + ((MemberExpression)expression).Member.Name + "=1)";
base.IsFinished = true;
}
base.Expression = expression;
base.Continue();
else
{
base.Expression = expression;
base.Start();
}
}
}
}

View File

@ -12,21 +12,12 @@ namespace SqlSugar
var expression = base.Expression as MemberExpression;
var isLeft = parameter.IsLeft;
var isSingle = parameter.Context.IsSingle;
string field = string.Empty;
field = isSingle ? expression.Member.Name : expression.Member.ToString();
base.IsFinished = true;
base.SqlWhere += string.Format(" {0} ", field);
if (isLeft == true)
string fieldName = string.Empty;
fieldName = isSingle ? expression.Member.Name : expression.Member.ToString();
parameter.BaseParameter.TempData.Add(ExpConst.FiledName, fieldName);
if (isLeft == null && base.SqlWhere == null)
{
base.SqlWhere += ExpTool.GetOperator(parameter.BaseExpression.NodeType);
}
else if (isLeft == false)
{
}
else
{
base.SqlWhere = fieldName;
}
}
}

View File

@ -97,6 +97,7 @@
<Compile Include="Entities\ConnectionConfig.cs" />
<Compile Include="Entities\DbColumnInfo.cs" />
<Compile Include="Entities\DbTableInfo.cs" />
<Compile Include="ExpressionsToSql\BinaryExpressionInfo.cs" />
<Compile Include="ExpressionsToSql\SugarParameter.cs" />
<Compile Include="ExpressionsToSql\ExpressionParameter.cs" />
<Compile Include="Entities\JoinQueryInfo.cs" />

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.