mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 13:34:32 +08:00
-
This commit is contained in:
parent
dd6a879edb
commit
fe59b5e7d9
Binary file not shown.
@ -17,12 +17,13 @@ namespace OrmTest
|
|||||||
public static string GetName() {
|
public static string GetName() {
|
||||||
return "a";
|
return "a";
|
||||||
}
|
}
|
||||||
|
public string x = "2";
|
||||||
public static string id { get; set;}
|
public static string id { get; set;}
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
Program.id = "xx";
|
Program.id = "xx";
|
||||||
string x = "1";
|
string x = "1";
|
||||||
Expression<Func<Student, bool>> exp = it => it.Name== GetName();
|
Expression<Func<Student, bool>> exp = it => it.Name==new Program().x;
|
||||||
// Expression<Func<Student, object>> exp = it => it.Name;
|
// Expression<Func<Student, object>> exp = it => it.Name;
|
||||||
ExpressionContext expContext = new ExpressionContext(exp, ResolveExpressType.Single);
|
ExpressionContext expContext = new ExpressionContext(exp, ResolveExpressType.Single);
|
||||||
// var x = expContext.GetFiledName();
|
// var x = expContext.GetFiledName();
|
||||||
|
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.
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -9,7 +10,34 @@ namespace SqlSugar
|
|||||||
public class MemberNewExpressionResolve : BaseResolve
|
public class MemberNewExpressionResolve : BaseResolve
|
||||||
{
|
{
|
||||||
public MemberNewExpressionResolve(ExpressionParameter parameter) : base(parameter) {
|
public MemberNewExpressionResolve(ExpressionParameter parameter) : base(parameter) {
|
||||||
|
var expression = base.Expression as MemberExpression;
|
||||||
|
var isLeft = parameter.IsLeft;
|
||||||
|
var isSingle = parameter.Context.IsSingle;
|
||||||
|
object value = null;
|
||||||
|
var isField = expression.Member is System.Reflection.FieldInfo;
|
||||||
|
var isProperty = expression.Member is System.Reflection.PropertyInfo;
|
||||||
|
if (isField)
|
||||||
|
{
|
||||||
|
value = ExpressionTool.GetFiledValue(expression.Expression as MemberExpression);
|
||||||
|
}
|
||||||
|
else if (isProperty)
|
||||||
|
{
|
||||||
|
value = ExpressionTool.GetPropertyValue(expression.Expression as MemberExpression);
|
||||||
|
}
|
||||||
|
if (parameter.BaseParameter.BinaryExpressionInfoList != null)
|
||||||
|
{
|
||||||
|
parameter.BaseParameter.BinaryExpressionInfoList.Add(new KeyValuePair<string, BinaryExpressionInfo>(ExpressionConst.BinaryExpressionInfoListKey, new BinaryExpressionInfo()
|
||||||
|
{
|
||||||
|
IsLeft = Convert.ToBoolean(isLeft),
|
||||||
|
Value = value,
|
||||||
|
ExpressionType = ExpressionConst.ConstantExpressionType
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (isLeft == null && base.Context.SqlWhere == null)
|
||||||
|
{
|
||||||
|
base.Context.SqlWhere = new StringBuilder();
|
||||||
|
base.Context.SqlWhere.Append(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,13 +15,13 @@ namespace SqlSugar
|
|||||||
var isLeft = parameter.IsLeft;
|
var isLeft = parameter.IsLeft;
|
||||||
var isSingle = parameter.Context.IsSingle;
|
var isSingle = parameter.Context.IsSingle;
|
||||||
object value = null;
|
object value = null;
|
||||||
var fieldInfo = expression.Member as System.Reflection.FieldInfo;
|
var isField = expression.Member is System.Reflection.FieldInfo;
|
||||||
var propertyInfo = expression.Member as System.Reflection.PropertyInfo;
|
var isProperty = expression.Member is System.Reflection.PropertyInfo;
|
||||||
if (fieldInfo != null)
|
if (isField)
|
||||||
{
|
{
|
||||||
value = ExpressionTool.GetFiledValue(expression);
|
value = ExpressionTool.GetFiledValue(expression);
|
||||||
}
|
}
|
||||||
else if (propertyInfo != null)
|
else if (isProperty)
|
||||||
{
|
{
|
||||||
value = ExpressionTool.GetPropertyValue(expression);
|
value = ExpressionTool.GetPropertyValue(expression);
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user