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

Support Regular Expressions for $in query builders on strings

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.4.2
    • Component/s: None
    • Labels:
    • Environment:
      CSharp Driver Linq to MongoDB

      In operators for query builders and Linq extension should take regular expressions as arguments when the operator is a string.

      Original report:
      --------------------------------
      Could you please verify if there is an option to build a linq query equivalent to the mongo query:

      db.Feeds.find({ShortDescription:{$in:[/sunil/, /raj/]}})

      I have tried:
      MongoCollection<BsonDocument> feedscollection = _db.database.GetCollection<BsonDocument>("Feeds");
      var feeds = (from f in feedscollection.AsQueryable<Feeds>()
      select f);
      string tags="1)Lorem ipsum sunil dolor sit amet, 2)Maecenas raj pretium laoreet nibh, 3)a rhoncus turpis cursus gravida";
      var searchwordlist = tags.ToLower().Split(new char[]

      { ',' }

      , StringSplitOptions.RemoveEmptyEntries).Select(s => string.Format("/

      {0}

      /", s)).ToList();
      feeds = feeds.Where(f => f.ShortDescription.In(searchwordlist));
      //With the mongo query I am getting the first and second sentence. But when I go with the linq -> mongo query, I am not getting any results.

            Assignee:
            Unassigned Unassigned
            Reporter:
            sunilrajkg Sunil Raj
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: