This commit is contained in:
sunkaixuan
2017-01-07 23:13:07 +08:00
parent 60eff8e71e
commit 24b53f7435
20 changed files with 44 additions and 12 deletions

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public class ExpressionParameter
{
public Expression Expression { get; set; }
public SqlSugarClient DbContext { get; set; }
}
}

View File

@@ -8,10 +8,13 @@ namespace SqlSugar
public class BaseResolve
{
protected Expression Expression { get; set; }
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; }
private BaseResolve()
{
@@ -23,7 +26,9 @@ namespace SqlSugar
public BaseResolve Start()
{
this.Index++;
this.IsFinished = false;
this.BaseExpression = null;
Expression exp = this.Expression;
if (exp is LambdaExpression)
{

View File

@@ -9,6 +9,15 @@ namespace SqlSugar
{
public BinaryExpressionResolve(Expression exp) : base(exp)
{
var expression = this.Expression as BinaryExpression;
base.BaseExpression = expression;
base.IsLeft = true;
base.Expression = expression.Left;
base.Start();
base.IsLeft = false;
base.Expression = expression.Right;
base.Start();
base.IsLeft = null;
base.Continue();
}
}

View File

@@ -10,7 +10,10 @@ namespace SqlSugar
{
public MemberExpressionResolve(Expression exp) : base(exp)
{
var isLeft = this.IsLeft;
this.IsLeft = null;
var isSingle=base.Context.IsSingle;
var expression = exp as MemberExpression;
}
}
}

View File

@@ -8,20 +8,20 @@ namespace SqlSugar
{
public class ExpressionContext : ExpResolveAccessory
{
private ResolveExpressType type { get; set; }
private Expression expression { get; set; }
private bool IsSingle { get { return this.type == ResolveExpressType.Single; } }
public ResolveExpressType Type { get; set; }
public Expression Expression { get; set; }
public bool IsSingle { get { return this.Type == ResolveExpressType.Single; } }
public ExpressionContext(Expression expression, ResolveExpressType type)
{
this.type = type;
this.expression = expression;
this.Type = type;
this.Expression = expression;
}
public string GetFiledName()
{
string reval = null;
LambdaExpression lambda = this.expression as LambdaExpression;
LambdaExpression lambda = this.Expression as LambdaExpression;
var isConvet = lambda.Body.NodeType.IsIn(ExpressionType.Convert);
var isMember = lambda.Body.NodeType.IsIn(ExpressionType.MemberAccess);
if (!isConvet && !isMember)
@@ -56,7 +56,7 @@ namespace SqlSugar
public string GetWhere()
{
BaseResolve resolve = new BaseResolve(this.expression);
BaseResolve resolve = new BaseResolve(this.Expression);
resolve.Context = this;
resolve.Start();
return resolve.SqlWhere;
@@ -75,5 +75,7 @@ namespace SqlSugar
base._Parameters = value;
}
}
public int Index { get; set; }
}
}

View File

@@ -97,6 +97,7 @@
<Compile Include="Entities\ConnectionConfig.cs" />
<Compile Include="Entities\DbColumnInfo.cs" />
<Compile Include="Entities\DbTableInfo.cs" />
<Compile Include="Entities\ExpressionParameter.cs" />
<Compile Include="Entities\JoinQueryInfo.cs" />
<Compile Include="Entities\Mapping\MappingColumn.cs" />
<Compile Include="Entities\Mapping\MappingTable.cs" />
@@ -135,9 +136,6 @@
<Compile Include="SqlSugarAccessory.cs" />
<Compile Include="SqlSugarClient.cs" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup>
<Content Include="Lib\Newtonsoft.Json.dll" />
</ItemGroup>

Binary file not shown.

Binary file not shown.

View File

@@ -3,3 +3,4 @@ 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.