Inheritance in MongoDb: how to request instances of defined type

后端 未结 5 1946
时光说笑
时光说笑 2021-02-10 16:41

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:28

    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'.

提交回复
热议问题