Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
None
-
None
-
None
Description
I have following scenario:
I'm using the the Mongo C# Driver with CosmosDB and I use a single collection to store different document types. I not really happy with this, but it seems recommended by Microsoft.
I get the collection:
_collection = database.GetCollection<object>("shared").OfType<T>();
When I insert a document the document the configured discriminator is used
Works:
_collection.InsertOne(document);
_collection.Find(filter).SingleOrDefault();
But when I try to query the collection the discriminator is always "FullTypeName, Assemby".
Doesn't work:
_collection.AsQueryable().ToList()
So the configured discriminator value is never used.
Currently it works by setting to discriminator to the value used by the query.
//does not support nested types
classMapInitializer.SetDiscriminator(typeof(T).FullName + ", " + typeof(T).Assembly.GetName().Name);
But we like to give a more functional names to the discriminator which don't break if we refactor.
I had a quick look and it seems that the filter of the OfTypeMongoCollection is not passed to the MongoQueryableImpl. And to can probably solved using a default expression that filters on the configured discriminator type.
Is this something that need to be supported by the library?
Any feedback is appriciated!
Tim