[CSHARP-430] LINQ does not support DateTime comparisons Created: 03/Apr/12  Updated: 02/Apr/15  Resolved: 04/Apr/12

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

Type: Bug Priority: Major - P3
Reporter: Zaid Masud Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: LINQ
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on CSHARP-431 Allow constant to appear on either si... Closed

 Description   

Following exception occurs when applying a comparison operator on a field of type DateTime:

Unsupported where clause: (DateTime:(2012-04-03T12:45:32.5348776Z) < s.CreatedOn)

The query is as follows:

.Where(s => DateTime.UtcNow < s.ExpireOn)

Note: This is supported by FluentMongo



 Comments   
Comment by Robert Stam [ 04/Apr/12 ]

See CSHARP-431 which has now been implemented. The constant (DateTime.UtcNow in your example) can now be on either side of the comparison operator.

Comment by Robert Stam [ 03/Apr/12 ]

The current LINQ implementation requires that the constant be on the right. So you can rewrite the where clause as:

.Where(s => s.ExpireOn > DateTime.UtcNow)

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