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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.