I have extended my entities to implement specific interfaces for its type. I am trying to perform the following query:
var results = from x in context.MyEnt
You can do the cast on the client, bypassing the entity framework query translation layer by calling AsEnumerable extension method:
return results.Any()
? results.AsEnumerable().Cast().ToList()
: null;
However, it's better to reverse the order of doing the Count check:
var list = results.AsEnumerable().Cast().ToList();
return list.Count == 0 ? null : list;