[CSHARP-632] Linq OrderBy throws when Expression type is object and property type is a value type Created: 20/Nov/12  Updated: 20/Mar/14  Resolved: 10/Dec/12

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

Type: Bug Priority: Major - P3
Reporter: Tim Kellogg Assignee: Craig Wilson
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to CSHARP-634 Over-eager expression tree normalizat... Closed

 Description   

We were using the .OrderBy extension method with a custom Expression. The Mongo driver seems to strip out the `Convert(...)` that the C# compiler adds (to box value types to reference types). i.e.

Expression<Func<TModel, DateTime>> sortExpression = m => m.UploadDate;
var query = collection.AsQueryable().OrderBy(sortExpression);
query.ToList(); // <-- fails

Pull request is following, on Github.



 Comments   
Comment by auto [ 10/Dec/12 ]

Author:

{u'date': u'2012-12-10T16:04:34Z', u'email': u'craiggwilson@gmail.com', u'name': u'Craig Wilson'}

Message: CSHARP-632: correct over-generalization of convert expression removal.
Branch: x2.0
https://github.com/mongodb/mongo-csharp-driver/commit/d0818073c0b4f008654981b801c7d0458f4f0e05

Comment by auto [ 10/Dec/12 ]

Author:

{u'date': u'2012-12-10T16:04:34Z', u'email': u'craiggwilson@gmail.com', u'name': u'Craig Wilson'}

Message: CSHARP-632: correct over-generalization of convert expression removal.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/619fe7f31dc96a5304c9250b4b52de65513adada

Comment by Craig Wilson [ 10/Dec/12 ]

In code review.

Comment by Tim Kellogg [ 20/Nov/12 ]

Pull request is at https://github.com/mongodb/mongo-csharp-driver/pull/140

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