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

Issue with Casting via C# LINQ Statements

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 2.19.1
    • Affects Version/s: 2.19.0
    • Component/s: LINQ3
    • None
    • 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?

      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.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            mmann@smartcert.tech Mark Mann
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: