MongoDb c# driver find item in array by field value

后端 未结 4 1115
再見小時候
再見小時候 2020-12-14 01:20

i found the way to check is the value contains in simple array :

var filter = Builders.Filter.AnyEq(x => x.Tags, \"mongodb\");
4条回答
  •  北海茫月
    2020-12-14 01:24

    There is ElemMatch

    var filter = Builders.Filter.ElemMatch(x => x.Tags, x => x.Name == "test");
    var res = await collection.Find(filter).ToListAsync()
    

提交回复
热议问题