你的位置:首页 > 数据库

[数据库]MongoDB的C# Driver 2.2 查询Mongo内嵌List字段


 var filterBuilder = Builders<WorkflowInstance>.Filter;

var filter = filterBuilder.Eq("WorkflowCode", workflowCode)
& filterBuilder.Eq("InstanceStatus", "WIP")
& filterBuilder.ElemMatch("WorkflowStateInstanceList", Builders<WorkflowStateInstance>.Filter.ElemMatch("ApproverUserList", Builders<InstanceStateApprover>.Filter.Eq("ApproverUser", userID))
& Builders<WorkflowStateInstance>.Filter.Eq("StateStatus", "WIP"));

 

List<WorkflowInstance> listInstance = InstanceMongo.Collection.Find(filter).ToList();

 注:WorkflowInstance/WorkflowStateInstance/InstanceStateApprover 为与Mongo对应的C#实体类