Desacralizing Multiple Types in same Collection

Hello forum,

This is my phone post on here, I am going to learn Mongo Db. I been reading the docs :slight_smile:
I trying to put it all together, and building some basic queries in c#

This is my question, the recommendation seems to be where possible keep the number of collections as low as possible and if required keep multiple types in the same collection

So lets say (silly example), I store a ‘cow’, ‘airplane’, and a ‘company’ in the same collection and they all have the field/property called url (unique). So I search on url and retrieve the doc

Then I have this command in my code:
Dim LocationCollection = Mongodb.GetCollection(Of AnimaDto)(“coreCollection”).Find(Filter).Project(Projection).First

I have to specify the type to desearalise to, and I dont know what the type is, because it might be an type of airplaneDto.

So the only way I can think to achieve this, except multiple collections is to store the type in the document and do something like this

Select Case coreCollection.GetValue(“DtoType”, nothing) and have filed called DtoType stored in the doc.

I know this is done with _t and polymorphism, but how can it be done with an a root class type

Kind Regards
Graham Mattingley

I ment first :slight_smile: