How to use MongoRegex (MongoDB C# Driver)
- by Hery
Has anyone have any idea how to use MongoRegex for the document search?
I attempted this, but returns nothing back:
var spec = new Document();
spec.Add("Name", new MongoRegex("/" + searchKey + "*/", "i"));
collection.Find(spec)
Wondering why it doesn't work, I tried to execute following command from the console:
db.things.find({"Name":/john*/i}) /* WORKS */
db.things.find({"Name":"/john*/i"}) /* DOESN'T WORK */
Is that possible that the driver applies double quotation to the regex?
Thanks..