Support for generics in razor view
It would be great if razor views could support generic models.
@Daniel Roth closed generics are great and in most cases are enough (for me) but there are several cases that you really needs an open generic and I think this kind of framework should have a nice answer for that need.
Pablo A. Revert commented
It would be great to have open generics!!!
Joy Roychowdhury commented
This is much needed creating a generic type of View which is common . That could ease a lot of scenarios
Martijn Hoekstra commented
This is especially useful for me for number types that don't share a common supertype (int, float, decimal, double, long, byte) and want to keep generic in the model, but use the same view for
Nico Sap commented
If i'm not mistaking, i used dynamic once in my views.
That could solve the problem, doesn't it? :)
This request is about open generics.
We currently support closed generics. Is that sufficient? Or is the request here specifically about open generics?
Tom Potts commented
It should support the where keyword too, either within the model statement or in a separate directive. For example,
@model IEnumerable<T> where T : MyBaseClass
Yes, it's really important feature.
At least support this for layouts.