![]() The cookie is used to store the user consent for the cookies in the category "Performance". This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. The cookies is used to store the user consent for the cookies in the category "Necessary". The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". The cookie is used to store the user consent for the cookies in the category "Analytics". ![]() These cookies ensure basic functionalities and security features of the website, anonymously. Necessary cookies are absolutely essential for the website to function properly. Here Author field value has to match exactly.ĭo you have any comments or ideas or any better suggestions to share? Where ‘julia robert’ is our exact search criteria. Let’s build a query to Get the list of items that ends with some search criteria.įilter = builder.Regex("Author", "^" + search + "$") Scenarios 3 – MongoDB C# Regex query end with ‘like’ The above query returns all the Authors which starts with “ J” values.įor Case insensitive query please prepare a query as explained in the above first example. Let’s build a query to get the list of items that start with some search criteria.įilter = builder.Regex("Author", "^" + search + ".*") Scenarios 2 – MongoDB C# Regex query start with ‘like’ The above query returns all the “ Authors” whose names contain either “J” or “j” Var queryExpr = new BsonRegularExpression(new Regex(search, RegexOptions.IgnoreCase)) The above query will return to me all the Author which contains the search criteria “J” or “j” in the field value.Ĭ# MongoDb regex query with case insensitive search Var queryExpr = new BsonRegularExpression(new Regex(search, RegexOptions.None)) Ĭ# MongoDb regex query with case-sensitive search “J” or “j” could be contained at the start or last or in the middle or anywhere else of Author’s name. Let’s build C# regex query for getting Author names where the name contains a word like “J” or “j” for the Author field. Here we shall be trying to search all the documents using a C# bson query similar to “ Like“. I have a sample MongoDB document as below in one of the collections. MongoDB Like Query without Regex– Guidelines.If you are interested to learn a query without a regex pattern, then please visit the below article, Scenarios 4 – C# Mongo Query Exact Match.Scenarios 3 – MongoDB C# Regex query end with ‘like’.Scenarios 2 – MongoDB C# Regex query start with ‘like’.C# MongoDb regex query with case insensitive search.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |