I need to be able to get something similar to the following to work:
Type type = ??? // something decided at runtime with .GetType or typeof;
object[] entityList = context.Resources.OfType<type>().ToList();
Is this possible? I am able to use .NET 4 if anything new in that allows this.
Purely on your question to use "Generics", No it is not possible.
Generics is a compile time feature, and not a runtime discovery. For runtime, you need to use Reflection or Dynamic.
You can call it by reflection:
An alternative would be to write your own
OfTypeAndToArray
generic method to do both bits of it, but the above should work.what about ...
A solution to handle multiple types is
Looks like you’ll need to use Reflection here...