liveBook · Manning

View model

A view model is a data structure that supplies a user-interface view with information formatted for display.

How 4 Manning books explain it

.NET MAUI in Action

A view model is a data transfer object that aggregates the data required to render a particular view, without providing application functionality.

How it is used
Aggregates all data needed to render a web view into one API response.
How deep it goes
Defines the DTO role and contrasts it with an MVVM ViewModel, without detailing API implementation.
Examples
Uses a sales leaderboard containing salesperson, monthly-total, and monthly-average data.
What you can do after
Evaluate/understand whether a view-specific aggregate DTO can replace multiple web-view API calls.

Read how .NET MAUI in Action explains view model →

Pro ASP.NET Core 7, Tenth Edition

A view model is the data supplied to a view for incorporation into its rendered output.

How it is used
Supplies controller-selected data to Razor views so actions can produce dynamic HTML responses.
How deep it goes
Works from a string through objects, collections, and composite classes, including typed access and nullable model handling.
Examples
Uses a time-dependent greeting, RSVP form and response, paged product catalog, and login form.
What you can do after
Build it from scratch by passing typed data from an MVC action and rendering its properties or collections in a Razor view.

Read how Pro ASP.NET Core 7, Tenth Edition explains view model →

ASP.NET Core in Action, 3e

A view model is an object or data structure containing the information a user-interface view requires to render a response.

How it is used
Uses view models to supply Razor views and public endpoints with presentation-ready data.
How deep it goes
Defines view models and explains their flow through Razor Pages and MVC controllers, including an EF Core projection.
Examples
Uses a recipe summary with formatted cooking time and an MVC error view model with a request ID.
What you can do after
Apply the pattern using ASP.NET Core and EF Core to pass or project presentation data into view models.

Read how ASP.NET Core in Action, 3e explains view model →

Functional Programming in C#, Second Edition

A view model is a data structure that presents information in a form suited to display in a user interface.

How it is used
Shapes client-facing data in an event-sourced system, with the query side populating views from stored events.
How deep it goes
Works through a bank-statement example, including event selection, balance aggregation, and transaction creation.
Examples
Uses a bank statement with monthly balances and transactions as its concrete example.
What you can do after
Build a view model from scratch by aggregating an account's events into statement balances and transactions.

Read how Functional Programming in C#, Second Edition explains view model →

What to know first

Related concepts

Questions about view model

What is view model?

A view model is a data structure that supplies a user-interface view with information formatted for display.

Which Manning books explain view model?

.NET MAUI in Action, Pro ASP.NET Core 7, Tenth Edition, ASP.NET Core in Action, 3e and Functional Programming in C#, Second Edition.

What should I know before learning view model?

Manning books that teach view model usually introduce business logic, C#, controller and handler first.

What is the difference between view model and data transfer object?

A view model is a data structure that supplies a user-interface view with information formatted for display. A data transfer object is a data-carrying structure that conveys selected information between software components or across boundaries without encapsulating substantial domain behavior.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.