Skip to content

Instantly share code, notes, and snippets.

@ivanfioravanti
Created October 25, 2013 15:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivanfioravanti/7156336 to your computer and use it in GitHub Desktop.
Save ivanfioravanti/7156336 to your computer and use it in GitHub Desktop.
MongoDB c# Case insensitive search
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