CHAPTER 7

image

Solution Design

7-1. Designing a View That Requires Data from Multiple Models

Problem

You have to design a complex view that contains data from many sources. You would like to use a strongly-typed view so that you can take advantage of IntelliSense in Visual Studio. You want to use an existing class library for your model, but it is made up of many classes. You do not see a way to add multiple models to a view. You want to know what is the best way to do this.

Solution

There are three possible approaches to solving this problem. One is to define a new model in the Model folder of your MVC project that is a composite that will contain ...

Get ASP.NET MVC 4 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.