Search code examples
asp.net-mvcsyntaxumbraco

How to use an IENumerable collection as model


I am using a partial view where I would like to use a collection of a custom model:

@model IENumerable<MyProject.Models.Currency>

This works but I would also like to use the built-in helpers etc from Umbraco, and the documentation says I have to inherit the UmbracoViewPage like so:

@inherits Umbraco.Web.Mvc.UmbracoViewPage<MyProject.Models.Currency>

This is however not a IENumerable anymore. Anyone knows the syntax to combine the IENumerable and @inherits syntax?


Solution

  • Sorry - easy one:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<IENumerable<MyProject.Models.Currency>>

    Hope it helps someone.