Using custom methods in linq to entities
问题 I have a Person table in my database that has NationalId field. Is there any way to load all Persons with even NationalId , using Ef code first and Linq to entities , without loading all Person s to memory? Somethings like: public bool IsEven(int number) { return number % 2 == 0; } var context = new MyContext(); var personsWithEvenNationalId = context.Persons .Where(x=> IsEven(x.NationalId)) .ToList(); 回答1: You would have to do your check inline var personsWithEvenNationalId = context.Persons