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.
22
OrmTest/ExpressionTest/Select.cs
Normal file
22
OrmTest/ExpressionTest/Select.cs
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -43,6 +43,7 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="ExpressionTest\Select.cs" />
|
||||||
<Compile Include="Models\School.cs" />
|
<Compile Include="Models\School.cs" />
|
||||||
<Compile Include="Models\Student.cs" />
|
<Compile Include="Models\Student.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
|
@@ -21,6 +21,11 @@ namespace OrmTest
|
|||||||
public static string id { get; set;}
|
public static string id { get; set;}
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
OrmTest.ExpressionTest.Select.Init();
|
||||||
|
|
||||||
|
|
||||||
Program.id = "xx";
|
Program.id = "xx";
|
||||||
string x = "1";
|
string x = "1";
|
||||||
Expression<Func<Student, object>> exp = it => new Program() { x=it.Name };
|
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.
Binary file not shown.
@@ -13,9 +13,9 @@ namespace SqlSugar
|
|||||||
private ExpressionContext() {
|
private ExpressionContext() {
|
||||||
|
|
||||||
}
|
}
|
||||||
public ExpressionContext(Expression expression, ResolveExpressType type)
|
public ExpressionContext(Expression expression, ResolveExpressType resolveType)
|
||||||
{
|
{
|
||||||
this.Type = type;
|
this.ResolveType = resolveType;
|
||||||
this.Expression = expression;
|
this.Expression = expression;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -23,7 +23,7 @@ namespace SqlSugar
|
|||||||
#region properties
|
#region properties
|
||||||
public IDbMethods DbMehtods { get; set; }
|
public IDbMethods DbMehtods { get; set; }
|
||||||
public int Index { get; set; }
|
public int Index { get; set; }
|
||||||
public ResolveExpressType Type { get; set; }
|
public ResolveExpressType ResolveType { get; set; }
|
||||||
public Expression Expression { get; set; }
|
public Expression Expression { get; set; }
|
||||||
public StringBuilder ResultString { get; set; }
|
public StringBuilder ResultString { get; set; }
|
||||||
public object ResultObj { get; set; }
|
public object ResultObj { get; set; }
|
||||||
@@ -31,7 +31,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return this.Type == ResolveExpressType.WhereSingle;
|
return this.ResolveType == ResolveExpressType.WhereSingle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public List<SugarParameter> Parameters
|
public List<SugarParameter> Parameters
|
||||||
|
@@ -13,7 +13,7 @@ namespace SqlSugar
|
|||||||
var isLeft = parameter.IsLeft;
|
var isLeft = parameter.IsLeft;
|
||||||
var isWhereSingle = parameter.Context.IsWhereSingle;
|
var isWhereSingle = parameter.Context.IsWhereSingle;
|
||||||
string fieldName = string.Empty;
|
string fieldName = string.Empty;
|
||||||
switch (parameter.Context.Type)
|
switch (parameter.Context.ResolveType)
|
||||||
{
|
{
|
||||||
case ResolveExpressType.WhereSingle:
|
case ResolveExpressType.WhereSingle:
|
||||||
fieldName = GetFieldNameByWhereSingle(parameter, expression, isLeft);
|
fieldName = GetFieldNameByWhereSingle(parameter, expression, isLeft);
|
||||||
|
@@ -11,7 +11,7 @@ namespace SqlSugar
|
|||||||
public MemberInitExpressionResolve(ExpressionParameter parameter) : base(parameter)
|
public MemberInitExpressionResolve(ExpressionParameter parameter) : base(parameter)
|
||||||
{
|
{
|
||||||
var expression = base.Expression as MemberInitExpression;
|
var expression = base.Expression as MemberInitExpression;
|
||||||
switch (parameter.Context.Type)
|
switch (parameter.Context.ResolveType)
|
||||||
{
|
{
|
||||||
case ResolveExpressType.WhereSingle:
|
case ResolveExpressType.WhereSingle:
|
||||||
break;
|
break;
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user