0

I am using MongoDB with C# Driver I try to fetch data based on search as an like from collection using following code:

col.Find(new BsonDocument(new BsonElement("Name", new BsonRegularExpression(search)))).ToList();

it's work for single field data search but how can do with this multiple field.

Pradip Talaviya
  • 399
  • 2
  • 8
  • 22
  • Did you check the tutorial on the official MongoDB page? https://docs.mongodb.com/getting-started/csharp/query/ – Daniele Tassone Aug 29 '17 at 12:14
  • I'm pretty sure this is what you are looking for ```col.Find(new BsonDocument(new BsonElement("Name", new BsonRegularExpression("test")), new BsonElement("Moar", new BsonRegularExpression("test")), new BsonElement("Fields", new BsonRegularExpression("test")))).ToList();``` Still not recommending it though... – Skami Aug 30 '17 at 16:18
  • `col.Find(new BsonDocument(new BsonElement("Name", new BsonRegularExpression("test")), new BsonElement("Moar", new BsonRegularExpression("test")), new BsonElement("Fields", new BsonRegularExpression("test")))).ToList();` it's not working always returning null list. i did't know which type match `and\or` – Pradip Talaviya Sep 01 '17 at 06:16

0 Answers0