Linq to Entities queries are converted to SQL, which must be executed by the DBMS, so you can only use code that can be translated into SQL. The C # custom method cannot be translated into SQL, so EF cannot translate the query. The fact that it is abstract does not matter.
A possible workaround would be to replace IsEqualRecord with a method that returns Expression<Func<DEntity, bool>> , which can be translated into SQL; you could do something like this:
var dbe = dbEntities.Where(MakeEqualityPredicate(me)); ... protected abstract Expression<Func<DEntity, bool>> MakeEqualityPredicate(MEntity m);
The MakeEqualityPredicate method should return an expression that compares DEntity with the given MEntity . For example, a derived class may implement it as follows:
protected override Expression<Func<DEntity, bool>> MakeEqualityPredicate(MEntity m) { return d => d.Id == m.Id; }
source share