[CSHARP-4773] Linq3Implementation: MongoDB.Driver.Linq.ExpressionNotSupportedException : Exists Created: 24/Aug/23  Updated: 31/Aug/23  Resolved: 31/Aug/23

Status: Closed
Project: C# Driver
Component/s: API
Affects Version/s: 2.21.0
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Sasan Pasha Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: Bug
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
backported by CSHARP-4743 Add support for DateTime.Date and Dat... Closed
Duplicate
duplicates CSHARP-4772 Add support for List<T>.Exists and Ar... Closed
Documentation Changes Summary:

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   

Summary

The use of  Linq "Exists" in the query is not supported.

MongoDB.Driver.Linq.ExpressionNotSupportedException: Expression not supported: p.OrganizationIds.Exists(o => (o == "045d9fd6-677d-4b9f-a288-4478e75c2da4")).
  at MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToAggregationExpressionTranslators.MethodCallExpressionToAggregationExpressionTranslator.Translate (MongoDB.Driver.Linq.Linq3Implementation.Translators.TranslationContext context, System.Linq.Expressions.MethodCallExpression expression) [0x01419] in <23bc2c72d0e04efa9278964cb99d6993>:0 
  at MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToAggregationExpressionTranslators.ExpressionToAggregationExpressionTranslator.Translate (MongoDB.Driver.Linq.Linq3Implementation.Translators.TranslationContext context, System.Linq.Expressions.Expression expression) [0x00133] in <23bc2c72d0e04efa9278964cb99d6993>:0 
  at MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToAggregationExpressionTranslators.MethodTranslators.AnyMethodToAggregationExpressionTranslator.Translate (MongoDB.Driver.Linq.Linq3Implementation.Translators.TranslationContext context, System.Linq.Expressions.MethodCallExpression expression) [0x000a4] in <23bc2c72d0e04efa9278964cb99d6993>:0 
  at MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToAggregationExpressionTranslators.MethodCallExpressionToAggregationExpressionTranslator.Translate (MongoDB.Driver.Linq.Linq3Implementation.Translators.TranslationContext context, System.Linq.Expressions.MethodCallExpression expression) [0x011f3] in <23bc2c72d0e04efa9278964cb99d6993>:0 
  at MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToAggregationExpressionTranslators.ExpressionToAggregationExpressionTranslator.Translate (MongoDB.Driver.Linq.Linq3Implementation.Translators.TranslationContext context, System.Linq.Expressions.Expression expression) [0x00133] in <23bc2c72d0e04efa9278964cb99d6993>:0 
  at MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToAggregationExpressionTranslators.BinaryExpressionToAggregationExpressionTranslator.Translate (MongoDB.Driver.Linq.Linq3Implementation.Translators.TranslationContext context, System.Linq.Expressions.BinaryExpression expression) [0x000c2] in <23bc2c72d0e04efa9278964cb99d6993>:0 
  at MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToAggregationExpressionTranslators.ExpressionToAggregationExpressionTranslator.Translate (MongoDB.Driver.Linq.Linq3Implementation.Translators.TranslationContext context, System.Linq.Expressions.Expression expression) [0x0010c] in <23bc2c72d0e04efa9278964cb99d6993>:0 
  at MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToFilterTranslators.ExpressionToFilterTranslator.TranslateUsingAggregationOperators (MongoDB.Driver.Linq.Linq3Implementation.Translators.TranslationContext context, System.Linq.Expressions.Expression expression) [0x00000] in <23bc2c72d0e04efa9278964cb99d6993>:0 
  at MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToFilterTranslators.ExpressionToFilterTranslator.Translate (MongoDB.Driver.Linq.Linq3Implementation.Translators.TranslationContext context, System.Linq.Expressions.Expression expression, System.Boolean exprOk) [0x0000b] in <23bc2c72d0e04efa9278964cb99d6993>:0 
  at MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToFilterTranslators.ExpressionToFilterTranslator.TranslateLambda (MongoDB.Driver.Linq.Linq3Implementation.Translators.TranslationContext context, System.Linq.Expressions.LambdaExpression lambdaExpression, MongoDB.Bson.Serialization.IBsonSerializer parameterSerializer, System.Boolean asRoot) [0x00093] in <23bc2c72d0e04efa9278964cb99d6993>:0 
  at MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToPipelineTranslators.WhereMethodToPipelineTranslator.Translate (MongoDB.Driver.Linq.Linq3Implementation.Translators.TranslationContext context, System.Linq.Expressions.MethodCallExpression expression) [0x0003e] in <23bc2c72d0e04efa9278964cb99d6993>:0 
  at MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToPipelineTranslators.ExpressionToPipelineTranslator.Translate (MongoDB.Driver.Linq.Linq3Implementation.Translators.TranslationContext context, System.Linq.Expressions.Expression expression) [0x003a1] in <23bc2c72d0e04efa9278964cb99d6993>:0 
  at MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToExecutableQueryTranslators.ExpressionToExecutableQueryTranslator.Translate[TDocument,TOutput] (MongoDB.Driver.Linq.Linq3Implementation.MongoQueryProvider`1[TDocument] provider, System.Linq.Expressions.Expression expression) [0x00015] in <23bc2c72d0e04efa9278964cb99d6993>:0 
  at MongoDB.Driver.Linq.Linq3Implementation.MongoQuery`2[TDocument,TOutput].ToCursorAsync (System.Threading.CancellationToken cancellationToken) [0x00000] in <23bc2c72d0e04efa9278964cb99d6993>:0 
  at MongoDB.Driver.IAsyncCursorSourceExtensions.ToListAsync[TDocument] (MongoDB.Driver.IAsyncCursorSource`1[TDocument] source, System.Threading.CancellationToken cancellationToken) [0x0000e] in <b1986f4c9c644071ac801bfae5975e5e>:0 
  at Infrastructure.Database.CosmoMongoDb.GetAccountsByOrganizationIdAsync (System.String organizationId) [0x001a7] in

Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

How to Reproduce

Steps to reproduce. If possible, please include a Short, Self Contained, Correct (Compilable), Example.

        var accounts = await AccountsCollection.AsQueryable().Where(a =>
                a.Profiles != null &&
                a.Profiles.Exists(p => p.OrganizationIds.Exists(o => o == organizationId))).ToListAsync()

 

 

Additional Background

Please provide any additional background information that may be helpful in diagnosing the bug.



 Comments   
Comment by PM Bot [ 24/Aug/23 ]

Hi sasan.pasha@gmail.com, thank you for reporting this issue! The team will look into it and get back to you soon.

Generated at Wed Feb 07 21:49:19 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.