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

Support OfType LINQ query operator

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.4.1
    • Affects Version/s: 1.4
    • Component/s: None
    • Labels:
      None

      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.

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

              Created:
              Updated:
              Resolved: