You have to be aware of the difference between IEnumerable and IQueryable
The advantage of IQueryable is that your query will be executed by the prodiver of the IQueryable, which is usually a database. Transferring your data from the database to local memory is a relatively slow process, so it is best to limit the data that must be transferred by letting the database do as much as possible.
The disadvantage of IQueryable is that it only knows the funcitonality of the provider. In case of SQL check the list of
Supported and Unsupported LINQ Methods (LINQ to Entities)
This means that you can't use your own functions like RemoveDiacritics.
The solution of your problem depends on how often you have to do this query, and whether this query must be performed very fast
If the query isn't done very often and it doesn't have to be at light speed, it is enough to add AsEnumerable()
var result = People
.AsEnumerable()
.Where(p => p.Name.ToUpper().RemoveDiacritics()....);
If your query is done very often and has to be really fast, consider extending your People table with a value that contains the value of Name.ToUpper().RemoveDiacritics()
class People
{
public string Name {get; set;}
public string NameWithoutDiacritics {get; set;}
...
}
Whenever your model Adds or Updates a People object, make sure NameWithoutDiacritics contains the correct value
public void Update(People people)
{
using (var dbContext = new MyDbContext())
{
var foundPeople = people.Find(people.Id);
foundPeople.Name = people.Name;
foundPeople.NameWithoutDiacritics = people.Name
.ToUpper()
.RemoveDiacritics();
...
dbContext.SaveChanges();
}
}
Change your query:
var result = People.Where(p => p.NameWithoutDiacritics.Contains(queryText));