mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 09:15:27 +08:00 
			
		
		
		
	- 解决 vb.net 表达式无法解析字符串比较;#140
This commit is contained in:
		@@ -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":
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user