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

NotSupportedException when using ToList on Embedded Documents

    • Type: Icon: New Feature New Feature
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.18.0
    • Affects Version/s: None
    • Component/s: Linq
    • None

      reproduce code

      var result = postCollection
      	.AsQueryable()
      	.Select(p => new
      	{
      		Id = p.Id,
      		Comments = p.Comments.ToList()
      	})
      	.ToList();
        Message: 
          System.NotSupportedException : The result operation MongoDB.Driver.Linq.Expressions.ResultOperators.ListResultOperator is not supported.
        Stack Trace: 
          AggregateLanguageTranslator.TranslatePipeline(PipelineExpression node)
          AggregateLanguageTranslator.TranslateValue(Expression node)
          AggregateLanguageTranslator.TranslateMapping(ProjectionMapping mapping)
          AggregateLanguageTranslator.TranslateNew(NewExpression node)
          AggregateLanguageTranslator.TranslateValue(Expression node)
          AggregateLanguageTranslator.Translate(Expression node, ExpressionTranslationOptions translationOptions)
          QueryableTranslator.TranslateProjectValue(Expression selector)
          QueryableTranslator.TranslateSelect(SelectExpression node)
          QueryableTranslator.Translate(Expression node)
          QueryableTranslator.TranslatePipeline(PipelineExpression node)
          QueryableTranslator.Translate(Expression node)
          QueryableTranslator.Translate(Expression node, IBsonSerializerRegistry serializerRegistry, ExpressionTranslationOptions translationOptions)
          MongoQueryProviderImpl`1.Translate(Expression expression)
          MongoQueryProviderImpl`1.Execute(Expression expression)
          MongoQueryableImpl`2.GetEnumerator()
          List`1.ctor(IEnumerable`1 collection)
          Enumerable.ToList[TSource](IEnumerable`1 source)
      

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            mj.ebrahimi72@gmail.com Mohamad Javad Ebrahimi
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: