From 7087b10a2ae5e42216671a9063e9b47a48615bcb Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Wed, 6 Feb 2019 17:53:40 +0800 Subject: [PATCH] Soupport Int.Parse --- .../MethodCallExpressionResolve.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs index 289a573fa..ea25050d3 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs @@ -402,6 +402,14 @@ namespace SqlSugar } else { + if (name == "Parse" && TempParseType.IsIn(UtilConstants.GuidType)) + { + name = "Equals"; + } + else if(name== "Parse") + { + name = "To"+TempParseType.Name; + } switch (name) { case "IIF": @@ -526,10 +534,30 @@ namespace SqlSugar { if (IsExtMethod(expression.Method.Name)) return true; + if (IsParseMethod(expression)) + return true; if (expression.Method.ReflectedType().FullName != ExpressionConst.SqlFuncFullName) return false; else return true; } + private Type TempParseType; + public bool IsParseMethod(MethodCallExpression expression) + { + if (expression.Method.Name == "Parse"&&expression.Method.DeclaringType.IsIn( + UtilConstants.DecType, + UtilConstants.DateType, + UtilConstants.DobType, + UtilConstants.GuidType, + UtilConstants.FloatType, + UtilConstants.ShortType, + UtilConstants.LongType, + UtilConstants.IntType)) + { + TempParseType = expression.Method.DeclaringType; + return true; + } + return false; + } } }