C# Mongodb 多层嵌套对象查询(字符串转换成查询语句)
public async Task<IList<Intent>> GetIntentFormEntity(string entityName)
{
var query = "{$or:[{'utterances.entities.entityId':'" + entityName + "'}, {'parameters.entityId':'" + entityName + "'}]}";
var filter = BsonSerializer.Deserialize<BsonDocument>(query);
var result = await _collectionIntent.FindAsync(filter);
return result.ToList();
}
var filter = BsonSerializer.Deserialize(query); --转换