Created
October 25, 2013 15:15
-
-
Save ivanfioravanti/7156336 to your computer and use it in GitHub Desktop.
MongoDB c# Case insensitive search
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MongoDB, c#: Case insensitive search | |
Query.Matches("FirstName", BsonRegularExpression.Create(new Regex(searchKey,RegexOptions.IgnoreCase))); | |
Query.Matches("FieldName", BsonRegularExpression.Create(new Regex(searchKey, RegexOptions.IgnoreCase))) | |
public User FindByEmail(Email email) | |
{ | |
return session.GetCollection<User>().AsQueryable() | |
.Where(u => u.EmailAddress.ToLower() == email.Address.ToLower()).FirstOrDefault(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment