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

StartsWith, Contains Linq expression bug

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None
    • Windows, VS2010

    Description

      When creating a query like so:

      public class MongoContext
      {
      public IQueryable<SomeObject> Objects
      {
      get

      { return collection.Linq(); }

      }
      }

      and calling it with the following:

      var objectsThatStartWithA = mongoContext.Objects.Where(o => o.Name.StartsWith("A"));

      Or:

      var objectsThatStartWithA = mongoContext.Objects.Where(o => o.Name.Contains("A"));

      You get the correct instances from Mongo but all properties are set to null.

      I would guess the best way to implement these would be to use regular expressions although I wasn't able to get these working correctly:

      db.ObjectsDb.Find(

      { Name: /"A"*/ }

      )
      And
      db.ObjectsDb.Find(

      { Name: /*"A"*/ }

      )

      Attachments

        Activity

          People

            craig.wilson@mongodb.com Craig Wilson
            nisbus nisbus
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: