상속: SqlExpression
예제 #1
0
 protected virtual string GetOperator(BinaryExpression u)
 {
     switch (u.NodeType)
     {
         case SqlExpressionType.Add:
             return "+";
         case SqlExpressionType.Subtract:
             return "-";
         case SqlExpressionType.Multiply:
             return "*";
         case SqlExpressionType.Divide:
             return "/";
         case SqlExpressionType.Modulo:
             return "%";
         case SqlExpressionType.And:
             return "AND";
         case SqlExpressionType.Or:
             return "OR";
         case SqlExpressionType.LessThan:
             return "<";
         case SqlExpressionType.LessThanOrEqual:
             return "<=";
         case SqlExpressionType.GreaterThan:
             return ">";
         case SqlExpressionType.GreaterThanOrEqual:
             return ">=";
         case SqlExpressionType.Equal:
             return "=";
         case SqlExpressionType.NotEqual:
             return "<>";
         case SqlExpressionType.RightShift:
             return ">>";
         case SqlExpressionType.LeftShift:
             return "<<";
         case SqlExpressionType.ExclusiveOr:
             return "^";
         default:
             throw new NotSupportedException("不支持的操作符:" + u.NodeType);
     }
 }
예제 #2
0
 protected override SqlExpression VisitBinary(BinaryExpression expr)
 {
     this.Write("(");
     this.Visit(expr.Left);
     this.Write(") ");
     this.Write(GetOperator(expr));
     this.Write(" (");
     this.Visit(expr.Right);
     this.Write(") ");
     return expr;
 }