This commit is contained in:
sunkaixuan
2017-01-14 15:16:20 +08:00
parent f19948e0fb
commit b776582c35
18 changed files with 34 additions and 6 deletions

Binary file not shown.

View File

@@ -0,0 +1,22 @@
using OrmTest.Models;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace OrmTest.ExpressionTest
{
public class Select
{
internal static void Init()
{
Expression<Func<Student, object>> exp = it => new Program() { x = it.Name };
ExpressionContext expContext = new ExpressionContext(exp, ResolveExpressType.WhereSingle);
expContext.ResolveType = ResolveExpressType.SelectSingle;
var x= expContext.ToResultString();
}
}
}

View File

@@ -43,6 +43,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ExpressionTest\Select.cs" />
<Compile Include="Models\School.cs" />
<Compile Include="Models\Student.cs" />
<Compile Include="Program.cs" />

View File

@@ -21,6 +21,11 @@ namespace OrmTest
public static string id { get; set;}
static void Main(string[] args)
{
OrmTest.ExpressionTest.Select.Init();
Program.id = "xx";
string x = "1";
Expression<Func<Student, object>> exp = it => new Program() { x=it.Name };

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

@@ -13,9 +13,9 @@ namespace SqlSugar
private ExpressionContext() {
}
public ExpressionContext(Expression expression, ResolveExpressType type)
public ExpressionContext(Expression expression, ResolveExpressType resolveType)
{
this.Type = type;
this.ResolveType = resolveType;
this.Expression = expression;
}
#endregion
@@ -23,7 +23,7 @@ namespace SqlSugar
#region properties
public IDbMethods DbMehtods { get; set; }
public int Index { get; set; }
public ResolveExpressType Type { get; set; }
public ResolveExpressType ResolveType { get; set; }
public Expression Expression { get; set; }
public StringBuilder ResultString { get; set; }
public object ResultObj { get; set; }
@@ -31,7 +31,7 @@ namespace SqlSugar
{
get
{
return this.Type == ResolveExpressType.WhereSingle;
return this.ResolveType == ResolveExpressType.WhereSingle;
}
}
public List<SugarParameter> Parameters

View File

@@ -13,7 +13,7 @@ namespace SqlSugar
var isLeft = parameter.IsLeft;
var isWhereSingle = parameter.Context.IsWhereSingle;
string fieldName = string.Empty;
switch (parameter.Context.Type)
switch (parameter.Context.ResolveType)
{
case ResolveExpressType.WhereSingle:
fieldName = GetFieldNameByWhereSingle(parameter, expression, isLeft);

View File

@@ -11,7 +11,7 @@ namespace SqlSugar
public MemberInitExpressionResolve(ExpressionParameter parameter) : base(parameter)
{
var expression = base.Expression as MemberInitExpression;
switch (parameter.Context.Type)
switch (parameter.Context.ResolveType)
{
case ResolveExpressType.WhereSingle:
break;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.