- 解决 vb.net 表达式无法解析字符串比较;#140

This commit is contained in:
28810
2019-12-15 13:04:08 +08:00
parent f162520202
commit c7b63ef474
5 changed files with 70 additions and 0 deletions

View File

@ -417,6 +417,20 @@ namespace FreeSql.Internal
}
public string ExpressionBinary(string oper, Expression leftExp, Expression rightExp, ExpTSC tsc)
{
if (leftExp.NodeType == ExpressionType.Call &&
rightExp.NodeType == ExpressionType.Constant &&
new[] { "=", "<>" }.Contains(oper))
{
var leftExpCall = leftExp as MethodCallExpression;
//vb 语法,将字符串比较转换为了 CompareString
if (leftExpCall.Method.Name == "CompareString" &&
leftExpCall.Method.DeclaringType?.FullName == "Microsoft.VisualBasic.CompilerServices.Operators" &&
leftExpCall.Arguments.Count == 3 &&
leftExpCall.Arguments[2].Type == typeof(bool) &&
rightExp.Type == typeof(int) &&
(int)(rightExp as ConstantExpression).Value == 0)
return ExpressionBinary(oper, leftExpCall.Arguments[0], leftExpCall.Arguments[1], tsc);
}
switch (oper)
{
case "OR":