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

OfType is not supported with the configured discriminator convention exception

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: 3.0.0
    • Component/s: API
    • None
    • Dotnet Drivers

      Summary

      After upgrade to v3.0.0 simple OfType() query on polymorphic collection throws System.NotSupportedException: OfType is not supported with the configured discriminator convention.

      In previous versions worked fine.

      How to Reproduce

       

      var client = new MongoClient("mongodb://root:root@localhost:27017");
      var collection = client.GetDatabase("test").GetCollection<Animal>("animals"); 
      var dogs = collection.OfType<Dog>().Find(Builders<Dog>.Filter.Empty).ToList();  
      
      [BsonKnownTypes(typeof(Dog))]
      public abstract class Animal 
      { 
          public ObjectIdId { get; set; } 
      }
      public class Dog : Animal
      {}  

       

            Assignee:
            adelin.mbidaowona@mongodb.com Adelin Mbida Owona
            Reporter:
            anatoliy.rabchevskiy Kool Booluk
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: