[CSHARP-4596] LINQ error in v2.19.1 Created: 04/Apr/23  Updated: 14/Sep/23  Resolved: 14/Sep/23

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

Type: Bug Priority: Unknown
Reporter: Wassim Khalil Assignee: Robert Stam
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates CSHARP-4566 Matching on char? throws an Expressio... In Progress
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

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



 Comments   
Comment by Robert Stam [ 14/Sep/23 ]

This ticket is a duplicate of CSHARP-4566 because it's just another example of an issue with numeric conversions (just that different types are involved in this ticket than in CSHARP-4566).

I have verified that the changes for CSHARP-4566 address this issue also.

Comment by Wassim Khalil [ 20/Jun/23 ]

Hi robert@mongodb.com, can you please provide an update on this. It's still broken in the latest version.

Comment by Robert Stam [ 04/Apr/23 ]

Thank you for reporting this issue. I am sorry that you are affected by it.

I am researching how to fix it.

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