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

Query MongoDb sublists with C# LINQ regex

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • None
    • 2.2.3
    • Linq
    • None

    Description

      As posted here:
      http://stackoverflow.com/questions/35863999/query-mongodb-sublists-with-c-sharp-linq-regex

      Regex IsMatch does not seem to work on list-properties although the same LINQ query runs fine on a standard list.

      I.e. given

      public class Car

      { public string Name; public List<string> Colors; }

      this only works for plain list LINQ:

      var regex = new Regex("^Blue.*");
      var matchingCars = carCollection.Where(x => x.Colors.Any(y => regex.IsMatch));

      The above just silently returns an empty queryable.

      Attachments

        Activity

          People

            Unassigned Unassigned
            pantosh Søren Holstebroe
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: