For SEO, I delete Turkish characters and spaces.
But I can't format the LINQ parameter, it gives the error.
The LINQ expression 'DbSet .Where(p => p.ProductNameTR .trCharToEnChar() == __productName_0)' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync(). See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
public List<TEntity> GetAll(Expression<Func<TEntity, bool>> filter = null)
{
TContext context = new TContext();
return filter == null ?
context.Set<TEntity>().ToList() :
context.Set<TEntity>().Where(filter).ToList();
}
public static string trCharToEnChar(this string str)
{
var newStr = "";
for (int i = 0; i < str.Length; i++)
{
newStr = str.Replace(" ", "_");
newStr = newStr.Replace("ı", "i");
newStr = newStr.Replace("ö", "o");
newStr = newStr.Replace("ü", "u");
newStr = newStr.Replace("ğ", "g");
newStr = newStr.Replace("ş", "s");
newStr = newStr.Replace("ç", "c");
newStr = newStr.Replace("ü", "u");
}
return newStr;
}
public List<Products> GetProductsByProductNameTextConvert(string productName)
{
return _productDal.GetAll(p => p.ProductNameTR.trCharToEnChar() == productName);
}