Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You should create separate viewmodel classes for a number of reasons.</p> <p>It is best to use separate viewmodel classes so that you do not overexpose your model. In the case where you use an entity class with 10 fields as a view model, and you only want to expose 5 of them, a malicious user may post the extra data with a querystring and the automatic bind may fuse that in without you realizing it.</p> <p>In your example case, you may want to use entirely different names for the fields. This is a perfect candidate for making a custom viewmodel for your entity class.</p> <p>Separating these concerns will help your application be more re-usable in the future, and easier to test / debug in the present. If you find yourself in the situation where there are too many view models, consider factoring out these different controllers, views, and models, into separate areas ( <a href="http://www.codeguru.com/csharp/.net/net_asp/mvc/article.php/c20227/Using-Areas-in-ASPNET-MVC-Application.htm" rel="nofollow">blog on areas</a> ).</p> <p>As a side note, if you want to format the JSON it may be easier to do it after the fact in javascript rather than before hand because usually editing the JSON serializer class is a large endeavor. You could write a script which went through and automatically converted camel case to <code>_</code> separated lower case. A downside to doing that would be that it could have unintended affects in the future if you did not expect the functionality to perform like that.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload