Browse Source

Soupport Int.Parse

pull/12/MERGE
sunkaixuan 6 years ago
parent
commit
7087b10a2a
  1. 28
      Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs

28
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;
}
}
}

Loading…
Cancel
Save