Inheritance in MongoDb: how to request instances of defined type

后端 未结 5 1944
时光说笑
时光说笑 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:20

    If the only concern is hardcoding class name, you can do something like this:

    collection = db.GetCollection("Animals");
    var query = Query.EQ("_t", typeof(Cat).Name);
    var cursor = collection.Find(query);
    

提交回复
热议问题