[CSHARP-4522] Issue with Casting via C# LINQ Statements Created: 09/Feb/23  Updated: 28/Oct/23  Resolved: 22/Feb/23

Status: Closed
Project: C# Driver
Component/s: LINQ3
Affects Version/s: 2.19.0
Fix Version/s: 2.19.1

Type: Bug Priority: Unknown
Reporter: Mark Mann Assignee: Robert Stam
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Zip Archive MongoExperiment.zip    
Documentation Changes: Not Needed
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   

Creating the issue from forum post: https://www.mongodb.com/community/forums/t/issue-with-2-18-to-2-19-nuget-upgrade-of-mongodb-c-driver/211894/10

 

The problem is when attempting to cast an object as a particular type in a C# LINQ statement to satisfy the C# compiler and access properties, the mongo driver(according to the person who responded in the forum) is attempting to do a server-side $convert

 

This just started after upgrading from the C# Nuget 2.18 to 2.19. I've uploaded a simple test solution which demonstrates this. 

 

I cannot use the following: public static T UpsertThing<T>( IMongoDatabase DB, Expression<Func<T, bool>> filter, T record) where T: AMongoThing

 

because we potentially cast as multiple different objects depending on the query and security we are attempting to achieve.



 Comments   
Comment by Githook User [ 24/Mar/23 ]

Author:

{'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}

Message: CSHARP-4522: Issue with Casting via C# LINQ Statements.
Branch: v2.19.x
https://github.com/mongodb/mongo-csharp-driver/commit/bf946856cb8465580e193c1c989c5ce9130bad56

Comment by Githook User [ 22/Feb/23 ]

Author:

{'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}

Message: CSHARP-4522: Issue with Casting via C# LINQ Statements.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/d46fe62fb159296ffaac6859935fd269d157e049

Comment by Robert Stam [ 09/Feb/23 ]

Thank you for reporting this issue. I will begin investigating it soon.

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