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

LINQ error in v2.19.1

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

      Summary

      When running the following LINQ query in C# driver v2.19.1 the following error is returned. This used to work in v2.19.0

       

      > MongoDB.Driver.Linq.ExpressionNotSupportedException: 'Expression not supported: 5 in (Convert(record.DateTimeUtc.Subtract(5/03/2023 6:03:13 AM, millisecond), Double) / 5) because it was not possible to determine how to serialize the constant.'

       

      The query

      ```csharp
      var result = collection
          .AsQueryable()
          .Select(record => record.DateTimeUtc.Subtract(startTime, DateTimeUnit.Millisecond) / (double)5)
          .ToList();
      ```

      Environment

      C# Driver 2.19.1

      Windows 11 64-bit x86

      How to Reproduce

      Run above query in version 2.19.1

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            wassimk@vypex.com Wassim Khalil
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: