tag:blogger.com,1999:blog-15136575.post5558380428965698222..comments2023-10-17T12:00:16.772+01:00Comments on Code rant: A Custom ASP.NET MVC Model Binder for RepositoriesMike Hadlowhttp://www.blogger.com/profile/16441901713967254504noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-15136575.post-76710127848774400852012-11-02T19:14:30.734+00:002012-11-02T19:14:30.734+00:00Hello Mike
The problem with the view-model-approa...Hello Mike<br /><br />The problem with the view-model-approach is that developers fill up the codebase with copies of entities, each tailored to each view, diluting the responsibilities represented by the properties on the entities, creating a high risk of shotgun surgery when an entity's interface changes.<br /><br />So, your model binder seems like the approach that should always be used when presenting a domain entity, saving the view-model-approach for when you want to present a complex or compound model.<br /><br />Any thoughts?<br /><br />Alex MainesAlex Maineshttps://www.blogger.com/profile/00940351913334358681noreply@blogger.comtag:blogger.com,1999:blog-15136575.post-47015824042476708572010-09-14T14:15:06.755+01:002010-09-14T14:15:06.755+01:00Hi Jaap,
This works with MVC 2.0. Have a look at ...Hi Jaap,<br /><br />This works with MVC 2.0. Have a look at the Suteki Shop source to see how it's configured:<br /><br />http://code.google.com/p/sutekishop/source/browse/trunk/Suteki.Shop/Suteki.Shop/Global.asax.cs<br /><br />and<br /><br />http://code.google.com/p/sutekishop/source/browse/trunk/Suteki.Shop/Suteki.Shop/IoC/ContainerBuilder.csMike Hadlowhttps://www.blogger.com/profile/16441901713967254504noreply@blogger.comtag:blogger.com,1999:blog-15136575.post-55541770791518696042010-09-14T12:29:02.030+01:002010-09-14T12:29:02.030+01:00Hi Mike,
Which version of asp.net mvc is used? Ho...Hi Mike,<br /><br />Which version of asp.net mvc is used? How did you configure your model binder?<br /><br />Thanks Jaapjtaalhttps://www.blogger.com/profile/09595621448788771890noreply@blogger.comtag:blogger.com,1999:blog-15136575.post-50866150479859884912010-04-06T09:51:39.037+01:002010-04-06T09:51:39.037+01:00Anonymous,
Yes, I think it's an interesting d...Anonymous,<br /><br />Yes, I think it's an interesting debate. As I implied in the post, if you're doing anything complex, you are much better off with the view-model approach.<br /><br />If I need to do extra validation, I can extend EntityModelBinder and override the ValidateEntity method.Mike Hadlowhttps://www.blogger.com/profile/16441901713967254504noreply@blogger.comtag:blogger.com,1999:blog-15136575.post-53428912167139351332010-04-06T09:46:07.108+01:002010-04-06T09:46:07.108+01:00I used to do something like this before but change...I used to do something like this before but changed my mind when i wanted better validation and client-side logic. I still do it for Show-requests though.<br /><br />Ie, instead of using Show(int id) i use Show(MyEntity entity). But for Edit/Create scenarios I use a view-model.Anonymousnoreply@blogger.com