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

Support Union via $unionWith in LINQ3

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Unknown Unknown
    • 2.19.2
    • None
    • LINQ3
    • None
    • Fully Compatible
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

    Description

      Repro with 2.19.1:

      using MongoDB.Bson;
      using MongoDB.Driver;
       
      var client = new MongoClient();
      var db = client.GetDatabase("test");
      var coll1 = db.GetCollection<BsonDocument>("coll1");
      var coll2 = db.GetCollection<BsonDocument>("coll2");
       
      var query = coll1.AsQueryable().Union(coll2.AsQueryable());
       
      var results = query.ToList();
      

      Output:

      Unhandled exception. MongoDB.Driver.Linq.ExpressionNotSupportedException: Expression not supported: test.coll1.Aggregate([]).Union(test.coll2.Aggregate([])).
         at MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToPipelineTranslators.ExpressionToPipelineTranslator.Translate(TranslationContext context, Expression expression)
         at MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToExecutableQueryTranslators.ExpressionToExecutableQueryTranslator.Translate[TDocument,TOutput](MongoQueryProvider`1 provider, Expression expression)
         at MongoDB.Driver.Linq.Linq3Implementation.MongoQuery`2.Execute()
         at MongoDB.Driver.Linq.Linq3Implementation.MongoQuery`2.GetEnumerator()
         at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
         at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
         at Program.<Main>$(String[] args) in /Users/james/Dropbox/code/cases/csharp4627/Program.cs:line 11
      

      Attachments

        Activity

          People

            oleksandr.poliakov@mongodb.com Oleksandr Poliakov
            james.kovacs@mongodb.com James Kovacs
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: