Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-2223

Unhandled mongo expression type: Pipeline when using more than one accumulator

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.14.0
    • Affects Version/s: 2.5
    • Component/s: Linq, LINQ3
    • Environment:
      Visual Studio 2017, both .Net framwork and .Net core.

      Below query fails because Compare function in ExpressionComparer class in ExpressionComparer.cs file doesn't implement comparison for Pipeline typed expressions:

      case ExpressionType.Extension:
      var extensionA = (ExtensionExpression)a;
      var extensionB = (ExtensionExpression)b;
      if (extensionA.ExtensionType != extensionB.ExtensionType)

      { return false; }

      switch (extensionA.ExtensionType)
      {
      case ExtensionExpressionType.Accumulator:
      return CompareAccumulator((AccumulatorExpression)extensionA, (AccumulatorExpression)extensionB);
      case ExtensionExpressionType.Document:
      return CompareDocument((DocumentExpression)a, (DocumentExpression)b);
      case ExtensionExpressionType.FieldAsDocument:
      return CompareDocumentWrappedField((FieldAsDocumentExpression)a, (FieldAsDocumentExpression)b);
      case ExtensionExpressionType.Field:
      return CompareField((FieldExpression)a, (FieldExpression)b);
      case ExtensionExpressionType.SerializedConstant:
      return CompareSerializedConstant((SerializedConstantExpression)a, (SerializedConstantExpression)b);

      • //THIS IS MISSING
        case ExtensionExpressionType.Pipeline:
        return ComparePipelineExpression((PipelineExpression)a, (PipelineExpression)b);
        *
        //THIS EXCEPTION IS THROWN
        default:
        throw new MongoInternalException(string.Format("Unhandled mongo expression type: ' {0}

        '", extensionA.ExtensionType));
        }

      Here is the query:
      in var Q = DB.Orders
      .AsQueryable()
      .Where(o => o.Status == Order.Statuses.Shipped && o.PurchaseDateTime >= DateTime.Now.Subtract(new TimeSpan(30, 0, 0, 0)) && o.PurchaseDateTime <= DateTime.Now)
      .Join(DB.OrderFinances.AsQueryable(), outer => outer.OrderId, inner => inner.OrderId, (inner, outer) => new

      { OrderData = inner, OrderFinancesData = outer }

      )
      .GroupBy(o => new

      { o.OrderData.PurchaseDateTime.Year, o.OrderData.PurchaseDateTime.Month, o.OrderData.FulfillmentChannel }

      )
      .Select(o => new

      { TotalRevenue = o.Sum(x => x.OrderData.Items.Sum(it => it.ItemPrice.Amount)), TotalRevenue2 = o.Sum(x => x.OrderData.Items.Sum(it => it.ItemPrice.Amount)), }

      );

      var R = Q.ToList();}}

            Assignee:
            Unassigned Unassigned
            Reporter:
            baris@saydag.com Baris Saydag
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: