asp.net-mvc-viewmodel

Using a PagedList with a ViewModel ASP.Net MVC

独自空忆成欢 提交于 2019-11-26 10:31:54
问题 I\'m trying to using a PagedList in my ASP.Net application and I found this example on the Microsoft website http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/sorting-filtering-and-paging-with-the-entity-framework-in-an-asp-net-mvc-application How is it possible to use a PagedList in a complex situation that uses a ViewModel? I\'m trying to add a PagedList without success to the Instructor example posted here: http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc

ViewModels in MVC / MVVM / Separation of layers- best practices?

空扰寡人 提交于 2019-11-26 03:58:28
问题 I\'m fairly new to the using ViewModels and I wonder, is it acceptable for a ViewModel to contain instances of domain models as properties, or should the properties of those domain models be properties of the ViewModel itself? For example, if I have a class Album.cs public class Album { public int AlbumId { get; set; } public string Title { get; set; } public string Price { get; set; } public virtual Genre Genre { get; set; } public virtual Artist Artist { get; set; } } Would you typically

ViewModel Best Practices

孤人 提交于 2019-11-26 01:23:25
问题 From this question, it looks like it makes sense to have a controller create a ViewModel that more accurately reflects the model that the view is trying to display, but I\'m curious about some of the conventions (I\'m new to the MVC pattern, if it wasn\'t already obvious). Basically, I had the following questions: I normally like to have one class/file. Does this make sense with a ViewModel if it is only being created to hand off data from a controller to a view? If a ViewModel does belong in