mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-20 02:29:39 +08:00
Code optimization
This commit is contained in:
33
Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/ErrorMessage.cs
Normal file
33
Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/ErrorMessage.cs
Normal file
@@ -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)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -19,12 +19,5 @@ namespace SqlSugar
|
|||||||
public readonly static Type MemberExpressionType = typeof(MemberExpression);
|
public readonly static Type MemberExpressionType = typeof(MemberExpression);
|
||||||
public readonly static Type ConstantExpressionType = typeof(ConstantExpression);
|
public readonly static Type ConstantExpressionType = typeof(ConstantExpression);
|
||||||
public readonly static Type StringType = typeof(string);
|
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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -42,7 +42,7 @@ namespace SqlSugar
|
|||||||
case ExpressionType.MultiplyChecked:
|
case ExpressionType.MultiplyChecked:
|
||||||
return "*";
|
return "*";
|
||||||
default:
|
default:
|
||||||
Check.ThrowNotSupportedException(string.Format(ExpressionErrorMessage.OperatorError, expressiontype.ToString()));
|
Check.ThrowNotSupportedException(string.Format(ErrorMessage.OperatorError, expressiontype.ToString()));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -427,7 +427,7 @@ namespace SqlSugar
|
|||||||
|
|
||||||
private void CheckMethod(MethodCallExpression expression)
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -167,7 +167,7 @@
|
|||||||
<Compile Include="ExpressionsToSql\Method\SqlFunc.cs" />
|
<Compile Include="ExpressionsToSql\Method\SqlFunc.cs" />
|
||||||
<Compile Include="ExpressionsToSql\Common\BinaryExpressionInfo.cs" />
|
<Compile Include="ExpressionsToSql\Common\BinaryExpressionInfo.cs" />
|
||||||
<Compile Include="ExpressionsToSql\Common\ExpressionResult.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\Common\ExpressionResultAcceptType.cs" />
|
||||||
<Compile Include="ExpressionsToSql\Method\IDbMethods.cs" />
|
<Compile Include="ExpressionsToSql\Method\IDbMethods.cs" />
|
||||||
<Compile Include="ExpressionsToSql\ResolveItems\MemberConstExpressionResolve.cs" />
|
<Compile Include="ExpressionsToSql\ResolveItems\MemberConstExpressionResolve.cs" />
|
||||||
|
Reference in New Issue
Block a user