MongoDB C# Query for 'Like' on string

后端 未结 3 694
忘掉有多难
忘掉有多难 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:38

    MongoDB C# driver has a BsonRegex type that you can use.

    Regex is the closest you will get to the SQL LIKE statement.

    Note that prefixed Regexes can use indexes: /^Joe/ will use an index, /Joe/ will not.

提交回复
热议问题