I have been working out for a case-insensitive search for hours and I still can`t find a solution...
I have data stored in MongoDB and formatted like this :
{
id: 12345,
name: "foo",
area: ["US","California"],
...
}
And I wanna use query to find results, as a list, that area partially matches the area string. For example, if I want to find people who are in us, with lower case. My method looks like this:
public async Task<IEnumerable<Restaurant>> GetByArea(string area)
{
var result = await _context.Users
.Find(user => user.Area.Contains(area))
.ToListAsync();
try
{
return result;
}
catch (Exception e)
{
return null;
}
}
How should I modify my code to conform case-insensitive search? The IEqualityComparer's methods won't be translated to MongoDB query.