Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>The first case is good for simplicity.</strong> If you extend your model you will have to do changes on less places. It is not less secure. You can bypass creating or binding the hidden input fields by several ways.</p> <p>Use <code>BindAttribute</code> to bypass binding of property: </p> <pre><code>ActionResult Create([Bind(Exclude = "RootCategoryId")] SubCategoryHelper thisSubCategory) {//....} </code></pre> <p>Or <code>ScaffoldColumnAttribute</code> on the model class property (e.g. when you use edit templates):</p> <pre><code>[ScaffoldColumn(false)] public int RootCategoryId {get; set;} </code></pre> <p>Or just simple do not expose it (as you did in your example using the <code>Html.HiddenInput</code> helper).</p> <hr> <p>The second approach, you have described, is often called <strong>ViewModel pattern</strong>. It <strong>encourages seperation of your Presentation and Domain layer</strong>. The advantage is, that your domain model will not be polluted with presentation layer specific code (like various display attributes etc.). Hovewer it brings another overhead of mapping between domain models and view models.</p> <p>There is probably no genarel rule of thumb. It depends on type of your appliction. </p> <p><em>If it is basically some simple data driven CRUD application, you can easily stay with the first one. Nevertheless, when your application becomes larger, you will definetly appreciate the freedom of your hands on separate layers. And if your BLL code is used with some other kind of "client" (web service, desktop etc.) except the ASP MVC I would defintely go with the second option.</em> </p> <p>I also suggest to read this great article: <a href="http://blog.ploeh.dk/2012/02/09/IsLayeringWorthTheMapping.aspx" rel="nofollow">Is layering worth mapping</a></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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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