LINQ providers look at your expression tree and try to generate an equivalent TSQL (etc.). This only works for recognized methods or scripts for recognized expressions.
It cannot look at an arbitrary method in your C # code and execute it in the database.
But! You can simplify the request for it:
var hash = GenerateHashWithSalt(password, GetUserID(username); var count =context.Users.Count(u => u.Password == hash);
source share