From 2c6dbc33a875cb26356ac88de80a6ce4f66a3b1d Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Thu, 13 Apr 2023 22:23:57 +0800 Subject: [PATCH] Update exp to sql --- .../ResolveItems/MemberExpressionResolve.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs index 2034fdd42..45e34def7 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs @@ -455,6 +455,28 @@ namespace SqlSugar } else { + if (parameter?.OppsiteExpression != null) + { + var exp = ExpressionTool.RemoveConvert(parameter?.OppsiteExpression); + if (exp is MemberExpression) + { + var member = (exp as MemberExpression); + var memberParent = member.Expression; + if (memberParent != null && this.Context?.SugarContext?.Context != null) + { + var entity = this.Context.SugarContext.Context.EntityMaintenance.GetEntityInfo(memberParent.Type); + var columnInfo = entity.Columns.FirstOrDefault(it => it.PropertyName == member.Member.Name); + if (columnInfo?.SqlParameterDbType is Type) + { + var type = columnInfo.SqlParameterDbType as Type; + var ParameterConverter = type.GetMethod("ParameterConverter").MakeGenericMethod(columnInfo.PropertyInfo.PropertyType); + var obj = Activator.CreateInstance(type); + var p = ParameterConverter.Invoke(obj, new object[] { value, 100 + this.ContentIndex }) as SugarParameter; + value = p.Value; + } + } + } + } AppendValue(parameter, isLeft, value); } }