1
People I am using Entity Framework 6, Mysql, ASP.NET MVC.
The problem is this: when I do a search through the form (my search view) EF is case sensitive. When I do the query directly in Mysql, using Sqlyog for example, it makes no difference if I search upper or lower case, then I believe it is something with EF. Someone can give a help?
This is my code that receives the parameter (search text) and query in the database:
public dynamic GetAll(Func<TEntity, bool> predicate, int limit, ClassContexto contexto)
{
dynamic data = null;
try
{
data = limit == 0 ?
(from p in contexto.Set<TEntity>() select p).Where(predicate).ToList() :
(from p in contexto.Set<TEntity>() select p).Where(predicate).ToList().Take(limit);
}
catch (DbEntityValidationException e)
{
data = e.EntityValidationErrors;
foreach (var eve in e.EntityValidationErrors)
{
var x = eve.Entry.Entity.GetType().Name + " - - " + eve.Entry.State;
foreach (var ve in eve.ValidationErrors)
{
data = ve.PropertyName + "--" + ve.ErrorMessage;
}
}
}
catch (Exception erro)
{
try
{
data = erro.InnerException.ToString();
return data;
}
catch
{
data = erro.Message.ToString();
return data;
}
}
finally
{
}
return data;
}
In the bank, there is an "ANTONIO" record. If I search for "antonio", it is returned null
.
How can I change that?
Eduardo, I used your suggestion and it worked, thank you.
– alessandre martins
cool @alessandremartins . just one thing: when an answer solves your problem, you should mark it as "accept". more details on [tour]
– Eduardo Moreira