[CSHARP-4701] LINQ3 produces ExpressionNotSupported error on ContainsKey for DictionaryRepresentation.ArrayOfDocuments Created: 30/Jun/23  Updated: 03/Jul/23  Resolved: 03/Jul/23

Status: Closed
Project: C# Driver
Component/s: LINQ3
Affects Version/s: 2.20.0
Fix Version/s: None

Type: New Feature Priority: Unknown
Reporter: John Gonyo Assignee: Robert Stam
Resolution: Duplicate Votes: 0
Labels: LINQ3
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates CSHARP-4443 Support LINQ3 queries against all 3 p... Backlog
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

LINQ3 queries using ContainsKey on a Dictionary that is stored as DictionaryRepresentation.ArrayOfDocuments throws a ExpressionNotSupported exception.  ContainsKey support was added to dictionaries stored as DictionaryRepresentation.Document in CSHARP-4557 and this commit Support needed for the ArrayOfDocuments representation as well.

How to Reproduce

public class Model {
  [BsonDictionaryOptions(DictionaryRepresentation.ArrayOfDocuments)]
  public virtual Dictionary<string, string> Foo { get; set; }
}
 
collection.AsQueryable()
  .Where(x => x.Foo.ContainsKey("x")).ToList();

Additional Background

The LINQ2 code for this I found here 

 



 Comments   
Comment by Robert Stam [ 03/Jul/23 ]

Thank you for reporting this. We are aware that LINQ queries are currently only supported when the dictionary is represented in the database using the default `Document` representation.

We would like to expand LINQ support for the other dictionary representations as well, at least to the extent that is possible in those representations.

Please follow the existing CSHARP-4443 ticket for that.

Comment by PM Bot [ 30/Jun/23 ]

Hi jgonyo@snagajob.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:05 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.