Browse Source

Code optimization

pull/12/MERGE
sunkaixuan 7 years ago
parent
commit
3103d79485
  1. 33
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/ErrorMessage.cs
  2. 7
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/ExpressionConst.cs
  3. 33
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/ExpressionErrorMessage.cs
  4. 2
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/ExpressionTool.cs
  5. 2
      Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs
  6. 2
      Src/Asp.Net/SqlSugar/SqlSugar.csproj

33
Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/ErrorMessage.cs

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
internal static partial class ErrorMessage
{
internal static string OperatorError
{
get
{
return ErrorMessage.GetThrowMessage("Lambda parsing error: {0} does not support the operator to find!","拉姆达解析出错:不支持{0}此种运算符查找!");
}
}
internal static string ExpFileldError
{
get
{
return ErrorMessage.GetThrowMessage("Expression format error, correct format: it=>it.fieldName","表达示格式错误,正确格式: it=>it.fieldName");
}
}
internal static string MethodError
{
get
{
return ErrorMessage.GetThrowMessage("Expression parsing does not support the current function {0}. There are many functions available in the SqlFunc class, for example, it=>SqlFunc.HasValue(it.Id)", "拉姆达解析不支持当前函数{0},SqlFunc这个类里面有大量函数可用,也许有你想要的,例如: it=>SqlFunc.HasValue(it.Id)");
}
}
}
}

7
Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/ExpressionConst.cs

@ -19,12 +19,5 @@ namespace SqlSugar
public readonly static Type MemberExpressionType = typeof(MemberExpression);
public readonly static Type ConstantExpressionType = typeof(ConstantExpression);
public readonly static Type StringType = typeof(string);
internal static string GetThrowMessage(string enMessage, string cnMessage, params string[] args)
{
List<string> formatArgs = new List<string>() { enMessage, cnMessage };
formatArgs.AddRange(args);
return string.Format("\r\n English Message : {0}\r\n Chinese Message : {1}", formatArgs.ToArray());
}
}
}

33
Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/ExpressionErrorMessage.cs

@ -1,33 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
internal class ExpressionErrorMessage
{
internal static string OperatorError
{
get
{
return ExpressionConst.GetThrowMessage("Lambda parsing error: {0} does not support the operator to find!","拉姆达解析出错:不支持{0}此种运算符查找!");
}
}
internal static string ExpFileldError
{
get
{
return ExpressionConst.GetThrowMessage("Expression format error, correct format: it=>it.fieldName","表达示格式错误,正确格式: it=>it.fieldName");
}
}
internal static string MethodError
{
get
{
return ExpressionConst.GetThrowMessage("Expression parsing does not support the current function {0}. There are many functions available in the SqlFunc class, for example, it=>SqlFunc.HasValue(it.Id)", "拉姆达解析不支持当前函数{0},SqlFunc这个类里面有大量函数可用,也许有你想要的,例如: it=>SqlFunc.HasValue(it.Id)");
}
}
}
}

2
Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/ExpressionTool.cs

@ -42,7 +42,7 @@ namespace SqlSugar
case ExpressionType.MultiplyChecked:
return "*";
default:
Check.ThrowNotSupportedException(string.Format(ExpressionErrorMessage.OperatorError, expressiontype.ToString()));
Check.ThrowNotSupportedException(string.Format(ErrorMessage.OperatorError, expressiontype.ToString()));
return null;
}
}

2
Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs

@ -427,7 +427,7 @@ namespace SqlSugar
private void CheckMethod(MethodCallExpression expression)
{
Check.Exception(expression.Method.ReflectedType().FullName != ExpressionConst.SqlFuncFullName, string.Format(ExpressionErrorMessage.MethodError, expression.Method.Name));
Check.Exception(expression.Method.ReflectedType().FullName != ExpressionConst.SqlFuncFullName, string.Format(ErrorMessage.MethodError, expression.Method.Name));
}
}
}

2
Src/Asp.Net/SqlSugar/SqlSugar.csproj

@ -167,7 +167,7 @@
<Compile Include="ExpressionsToSql\Method\SqlFunc.cs" />
<Compile Include="ExpressionsToSql\Common\BinaryExpressionInfo.cs" />
<Compile Include="ExpressionsToSql\Common\ExpressionResult.cs" />
<Compile Include="ExpressionsToSql\Common\ExpressionErrorMessage.cs" />
<Compile Include="ExpressionsToSql\Common\ErrorMessage.cs" />
<Compile Include="ExpressionsToSql\Common\ExpressionResultAcceptType.cs" />
<Compile Include="ExpressionsToSql\Method\IDbMethods.cs" />
<Compile Include="ExpressionsToSql\ResolveItems\MemberConstExpressionResolve.cs" />

Loading…
Cancel
Save