In my generic abstract class
class SomeClass<T> where T : ISomeInterface
I have a method that calls my repository and pass a parameter Expression<Func<T, bool>>
parameter to tell him the 'where' condition.
As T implements ISomeInterface, the DebugView of the lambda passed brings me something like
...((ISomeInterface)$p).SomeInterfaceMember == ...
This causes Entity Framework throw an exception
Unable to cast the type 'MySomeTypeThatImplementsISomeInterfaceAndIsPassedAs[T]ToTheClass' to type 'ISomeInterface'. LINQ to Entities only supports casting Entity Data Model primitive types.
The method that I call is
IRepository<T>.Get(t => t.SomeInterfaceMember == 1)
Thanks for helping