2017-11-02 9 views
0

MongoDB에 다음 레코드가 있습니다. "월요일"필드에서 문자열을 검색하고 싶습니다. "learningexperience"필드를 검색하여 해당 필드의 특정 단어와 일치하는 모든 문서를 반환하고 싶습니다.C#으로 MongoDB의 객체 배열에서 문자열을 검색하는 방법

MongoDB/C#을 사용하는 방법을 잘 모르겠습니다. 어떤 도움이라도 환상적입니다.

{ 
    "_id" : ObjectId("59ee623844bd6b042809d492"), 
    "title" : "Zebra Room (2017-10-30)", 
    "weekcommencing" : "2017-10-30", 
    "monday" : [ 
     { 
      "categoryid" : "59ee610244bd6b042809d48d", 
      "category" : "Culture & Community", 
      "learningexperience" : "Dress up to reflect where i am from. Children are asked to dress in the national uniform of their origins." 
     }, 
     { 
      "categoryid" : "59edca4344bd6d1e200c3c32", 
      "category" : "Literacy & Numeracy", 
      "learningexperience" : "Today the children will be focusing on simple additions. For those more advance we will also have subtractions in place." 
     } 
] 
} 
+1

[MongoDB를 C#을 드라이버, 정규식을 사용하여 배열 요소에 의한 쿼리 (https : //로 stackoverflow.com/q/38699179/2313887)? –

답변

0

% keyword %와 (과) 같은 검색어로 검색하려는 경우. 당신은 시도 할 수도이 필터 (MongoDB를의 C#을 드라이버 2.0 이상)을 시도 할 수 있습니다 C 번호

db.tablename.find({"monday.learningexperience": /.*keyword.*/}) 

Builders<tablename>.Filter.Regex("monday.learningexperience", new BsonRegularExpression("keyword", "i"));