MongoDB C# Query for 'Like' on string

后端 未结 3 692
忘掉有多难
忘掉有多难 2020-12-09 09:06

i am using official mongodb c# driver. i want to query mongodb simliar to SQL Like something like db.users.find({name:/Joe/} in c# driver

3条回答
  •  鱼传尺愫
    2020-12-09 09:22

    c# query will looks like:

    Query.Matches("name", BsonRegularExpression.Create(new Regex("Joe")));
    

    Update:

    As per @RoberStam suggestion, there is more simple way to do this:

    Query.Matches("name", "Joe") 
    

提交回复
热议问题