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

Linq OrderBy throws when Expression type is object and property type is a value type

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.8
    • Affects Version/s: 1.6.1
    • Component/s: None
    • Labels:
      None

      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.

            Assignee:
            craig.wilson@mongodb.com Craig Wilson
            Reporter:
            tkellogg Tim Kellogg
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: