ViewModel concept still exists in ASP.NET MVC Core?

In previous versions of ASP.NET MVC, you will find information about ViewModels and how to use them in this version.

I wonder why I can not find information about this topic in ASP.NET Core MVC? Is there still a concept, and if so, where do I need to put them?

The question arises because I want to make a toolbar for projects. Projects are the main entry point to my web application. They have many relationships, for example, with milestones.

Models:

public class Project
{
    public int ProjectId { get; set; }
    public string Name { get; set; }

    public ICollection<Milestone> Milestones { get; set; }
    ...
}

public class Milestone
{
    public int MilestoneId { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
    public DateTime Deadline { get; set; }
    public int? ParentId { get; set; }
    public Milestone Parent { get; set; }

    public ICollection<Milestone> Childrens { get; set; }
    ...
}

Before ASP.NET Core, I created a ProjectDashboardViewModel to get information for the view. Can I use the same approach?

+4
source share
3 answers

" ?" " ?"

, ViewModel - .NET Core, -, "", .

" ASP.NET Core MVC"

. ASP.NET Core MVC :

MVC - , . - , . ViewModel , ; ViewModel .

HTML :

. , ( viewmodel, -), . .

MVC/Advanced/Application Parts , , .

. , , , .

: https://docs.microsoft.com/en-us/search/index?search= ViewModel & = ASP.NET + ​​

"..

( "" ), . , , , , , Project.

, Project, . , .., : Project, NumberInProgressPrjects, OverdueProjectsList ..

public class ProjectDashboardViewModel
{
    public Project Project { get; set; }
    public int NumberInProgressProjects { get; set; }
    public ICollection<OverdueProjectInfo> OverdueProjectsList { get; set; }
}

: , , , , ( ) , ViewData (, , ). , , , .NET MVC Core, MVC.

".. ?

, , , using, . , "ViewModels".

+13

ViewModel/MVVM (Model-View-ViewModel) - .

, , MVC, , .

+3

Source: https://habr.com/ru/post/1662057/


All Articles