EF Distinct (IEqualityComparer) Fehler
Guten Morgen!
Gegeben:
<code>public class FooClass { public void FooMethod() { using (var myEntity = new MyEntity) { var result = myEntity.MyDomainEntity.Where(myDomainEntity => myDomainEntity.MySpecialID > default(int)).Distinct(new FooComparer); } } } public class FooComparer : IEqualityComparer<MyEntity.MyDomainEntity> { public bool Equals(MyEntity.MyDomainEntity x, MyEntity.MyDomainEntity y) { return x.MySpecialID == y.MySpecialID; } public int GetHashCode(MyEntity.MyDomainEntity obj) { return obj.MySpecialID.GetHashCode(); } } </code>
Dies wird kompiliert, aber zur Laufzeit bekomme ich eineLinq to Entity could not translate Comparer
-Ausnahme.
Irgendwelche Vorschläge?