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

OrderBy has stopped working for LINQ Queries in latest driver.

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Works as Designed
    • Icon: Blocker - P1 Blocker - P1
    • None
    • 2.4.4
    • None
    • None
    • Windows 10 connecting to mongod version: 3.4.5 (WiredTiger) | SSL mode: preferSSL hosted at Mongo Labs

    Description

      I am surprised to see that ordering by date is not working properly no matter what I try on the latest C# driver. Pretty sure this was working before.

      Here are some examples where dates are not ordered properly and coming out of sequence:

       
      var row = mongoCollection.AsQueryable<EntityClass>()
                                           .OrderBy(p => p.MyDateTime.Value)
                                           .OrderBy(p => p.OtherId)
                                           .Where(p => p.MyId == myData.MyId)
                                           .FirstOrDefault();
       
      var row = (from p in mongoCollection.AsQueryable<EntityClass>()
                        where p.MyId == myData.MyId
                        orderby p.MyDateTime.Value ascending
                        orderby p.OtherId ascending
                        select p).FirstOrDefault();
       
      row = (from p in mongoCollection.AsQueryable<EntityClass>()
                 where p.MyId == myData.MyId &&
                            p.OtherId > row.OtherId
                 orderby p.MyDateTime.Value ascending
                 orderby p.OtherId ascending
                 select p).FirstOrDefault();
      
      

      None of these work. I get dates out of sequence as shown in the attachment. I even tried adding an index on the date column in the server - made no difference.

      Attachments

        Activity

          People

            robert@mongodb.com Robert Stam
            vdevappa@locusrobotics.com Vijay Devappa
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: