Inheritance in MongoDb: how to request instances of defined type

后端 未结 5 1785
迷失自我
迷失自我 2021-02-10 16:34

This is how I used to utilize inheritance in Entity Framework (POCO):

ctx.Animals // base class instances (all instances)
ctx.Animals.OfType  // inher         


        
5条回答
  •  情深已故
    2021-02-10 17:19

    Assuming your discriminators are functioning (_t is stored correctly for each document) then I think this is what you are looking for.

    var results = collection.AsQueryable().OfType
    

    Returns only those documents that are of type 'Cat'.

提交回复
热议问题