Search code examples
mongodbmongodb-.net-driversql-like

How do you do SQL Like operator in mongoDB using the official C# driver


How do you do the following SQL query in mongodb using the official c# Driver?

Select * from tblUser where FirstName Like '%as%'

Solution

  • I figured out how to do this. You have to use Query.Matches

    var query = Query.Matches("FirstName", ".*as.*");