2017-11-02 16 views
0

MongoDBに次のレコードがあります。私は "monday"フィールドで文字列を検索したい。私は "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")); 
関連する問題