Also, what if you prefer working with strongly typed view models?
This is where the EmmTi.KenticoCloudConsumer.EnhancedDeliver NuGet package (still in beta) comes to the rescue.
Nuget PackageThis project is available as a nuget package at https://www.nuget.org/packages/EmmTi.KenticoCloudConsumer.EnhancedDeliver/
To install EmmTi.KenticoCloudConsumer.EnhancedDeliver, run the following command in the Package Manager Console
Quick Setup Guide
Initial Setup1. Follow the steps in the Kentico Dancing Goat Example to setup a sample site.
2. Add the following config setting in appsettings of web.config. Tweak the cache time as you see fit.
Creating the View Model1. Create a new ViewModel and inherit from BaseContentItemViewModel
2. Add a ItemCodeName constant with the code name for the Kentico Content Type
3. Create public properties for other Content Elements
4. Override MapContentForType method and map each field - See example
The ControllerIn your Controller return the new ViewModel using the DeliveryFactory
The ViewUse the strongly typed model in your View
See a full sample siteClone an enhanced version of the Dancing Goat Sample site for a working example
It's just got the Homepage View converted to a strongly typed, locally cached version. I will be updating the rest of the views and code as and when I get some time.
Source CodeThe source code for EmmTi.KenticoCloudConsumer.EnhancedDeliver is available on github for you to fork and work on.
Contributions, pull requests and comments are welcome.