asp.net mvc - Is it wrong in MVC View Model -


i need little mvc view model. saw using mvc view model this. way writing more code.

 public class artist     {         public int artistid { get; set; }         public string namesurname { get; set; }         public int age { get; set; }     }     public class artistviewmodel     {         public int artistid { get; set; }         public string namesurname { get; set; }         public int age { get; set; }          public string whatever { get; set; }         public int iwant { get; set; }     } 

copy of main class. work. ok. cant this

public class artistviewmodel : artist     {         public string whatever { get; set; }         public int iwant { get; set; }     } 

or

public class artistviewmodel     {         public artist artist { get; set; }          public string whatever { get; set; }         public int iwant { get; set; }     } 

there lots of reasons doing separate view model domain objects

here few can think of right now.

=> view model representation(information) of data domain/entity

=> view model customize information view, may not allow/want display/edit columns of entity in particular view.

=> may have many view models filled data same domain object different views.

=> can restrict can edited/updated through view model.

if inherit viewmodel real entity, hacker can post data of properties of real entity though tried restricting through view

my english not if not understand thing please let me know try clear up


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -