0

I have this query running natively ok, but throws an exception when running in .net

FilterDefinition<BsonDocument> filter = "{'$and':[ {'A':{$ne:'1'}},{'B': {$regex:/.*Ios.*/i}}]}";
collection.Find(filter);

via .net I get the exception: JSON reader expected a string but found '/.*Ios.*/i'.

I believe it is because the regex value is not wrapped with quotes.

Whats the deal here?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
SexyMF
  • 10,657
  • 33
  • 102
  • 206
  • [this](http://stackoverflow.com/questions/3305561/how-to-query-mongodb-with-like) might help you – Neo-coder May 24 '15 at 18:48
  • 1
    Don't expect either part of the query to be any fast. `$ne` is slow, and non-rooted regexs are slower. As to the question, .net requires you to explicitly create a `BsonRegularExpression`. – mnemosyn May 24 '15 at 19:01
  • @yogesh - the problem is with the c# driver, what you have offered is not, thanks. – SexyMF May 25 '15 at 03:31
  • @mnemosyn please explain. this is the only way I see to do string,cintains, thanks – SexyMF May 25 '15 at 03:32

0 Answers0