In .NET Core 2.2, I used to use a helper class that decrypts the data from the database and retrieves the user information, but now I can't. I get an exception saying that it can't' be translated.
That's the same logic used in .NET Core 2.2
var cp = await Context.Company .Where(a => Encrypt.Decry(a.Email, a.Em) == login.Email && login.Password == Hash.get(a.Password)) .SingleOrDefaultAsync();
The exception :
The LINQ expression 'DbSet.Where(c => Encrypt.Decry(value: c.Email, sec: c.Em) == __login_Email_0 && __login_Password_1 == Hash.get(c.Password))' 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."}
I don't get why I should explicitly used
Update : So I tried to follow the example by adding
AsEnumerable but it must be with await and I get an error on
var cp = await Context.Company.AsAsyncEnumerable().Where(a => Encrypt.Decry(a.Email, a.Em) == login.Email && login.Password == Hash.get(a.Password)).SingleOrDefaultAsync();
EF Core can't translate
Encrypt.Decry to SQL query. That's why you see the error. You can load all data into memory and then execute
Prior to version 3.0, Entity Framework Core supported client evaluation anywhere in the query. For more information, see the previous versions section.
Most likely now it's implemented like this to avoid unintentional client evaluation where a lot of data can be loaded into memory. Now you should explicitly configure client evaluation.