| ViewModel, Partial Views and Layouts in Asp.Net Core
|
Showing posts with label View Model. Show all posts
Showing posts with label View Model. Show all posts
Saturday, May 18, 2019
ViewModel, Partial Views and Layouts in Asp.Net Core
Thursday, May 16, 2019
Creating a ViewModel object and bind it to the View
In the previous post we
created a custom controller and we developed our own view and it worked. There
is one think to note in that sample, the controller was passing a list of
Employee object will all the properties, but the view was displaying only
specific properties. Though this works it’s not efficient while displaying
larger lists, we end up fetching way too much data from the database but not
using it. To avoid this we have to create a custom ViewModel object with only properties used in the view. In this
sample we will modify the previous example to use a ViewModel object.
First create another folder inside the Models folder, name it ViewModel we will create all our ViewModel objects inside this folder. Next create a class EmployeeSummary.cs in this folder as follows.
First create another folder inside the Models folder, name it ViewModel we will create all our ViewModel objects inside this folder. Next create a class EmployeeSummary.cs in this folder as follows.
Subscribe to:
Posts (Atom)

