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

Support OfType LINQ query operator

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • 1.4.1
    • 1.4
    • None
    • None

    Description

      Assume D is a subclass of C:

      var query = collection.AsQueryable<C>().OfType<D>();

      or using query syntax and type comparisons support either of the following:

      var query = from c in collection.AsQueryable<C>() where c is D select c;
      var query = from c in collection.AsQueryable<C>() where c.GetType() == typeof(D) select c;

      The second example differs slightly in that it should not match subclasses of D.

      These would be translated into queries against the "_t" discriminator value.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: