<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: ASP.NET MVC Tip #1: Using Custom ViewModels with POST action methods</title>
	<atom:link href="http://devermind.com/linq/aspnet-mvc-using-custom-viewmodels-with-post-action-methods/feed/" rel="self" type="application/rss+xml" />
	<link>http://devermind.com/linq/aspnet-mvc-using-custom-viewmodels-with-post-action-methods/</link>
	<description>Adrian Grigore's software development weblog. Motto: I will not waste my time looking for a clever motto.</description>
	<lastBuildDate>Fri, 03 Sep 2010 13:31:04 +0200</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Adrian Grigore</title>
		<link>http://devermind.com/linq/aspnet-mvc-using-custom-viewmodels-with-post-action-methods/comment-page-1/#comment-572</link>
		<dc:creator>Adrian Grigore</dc:creator>
		<pubDate>Fri, 16 Jul 2010 07:47:42 +0000</pubDate>
		<guid isPermaLink="false">http://devermind.com/?p=102#comment-572</guid>
		<description>@Ross: Yes, but TryUpdateModel will not update a viewmodel from an DTO when constructing the view (GET request). 

Also, I don&#039;t like working with FormCollections for POST requests, because it makes unit testing less intuitive. Even though I&#039;ve writting a helper method that creates a fake http context from a model for unit testing, I still prefer custom ViewModels as POST action method parameters</description>
		<content:encoded><![CDATA[<p>@Ross: Yes, but TryUpdateModel will not update a viewmodel from an DTO when constructing the view (GET request). </p>
<p>Also, I don&#8217;t like working with FormCollections for POST requests, because it makes unit testing less intuitive. Even though I&#8217;ve writting a helper method that creates a fake http context from a model for unit testing, I still prefer custom ViewModels as POST action method parameters</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ross McLoughlin</title>
		<link>http://devermind.com/linq/aspnet-mvc-using-custom-viewmodels-with-post-action-methods/comment-page-1/#comment-571</link>
		<dc:creator>Ross McLoughlin</dc:creator>
		<pubDate>Thu, 15 Jul 2010 14:28:48 +0000</pubDate>
		<guid isPermaLink="false">http://devermind.com/?p=102#comment-571</guid>
		<description>@Adrian: 

Nice article.  I was stuck on this for a while this morning.  Just a quick point regarding your last post.  I have looked at automapper, and it does indeed look nice.  But does TryUpdateModel(,) in MVC 2 not do the same thing?

For example, I could easily map a FormCollection passed in as a parameter to an Action and map it to a Entity using this TryUpdateModel.</description>
		<content:encoded><![CDATA[<p>@Adrian: </p>
<p>Nice article.  I was stuck on this for a while this morning.  Just a quick point regarding your last post.  I have looked at automapper, and it does indeed look nice.  But does TryUpdateModel(,) in MVC 2 not do the same thing?</p>
<p>For example, I could easily map a FormCollection passed in as a parameter to an Action and map it to a Entity using this TryUpdateModel.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adrian Grigore</title>
		<link>http://devermind.com/linq/aspnet-mvc-using-custom-viewmodels-with-post-action-methods/comment-page-1/#comment-568</link>
		<dc:creator>Adrian Grigore</dc:creator>
		<pubDate>Fri, 25 Jun 2010 10:33:08 +0000</pubDate>
		<guid isPermaLink="false">http://devermind.com/?p=102#comment-568</guid>
		<description>Thanks for the hint! So far I&#039;ve been using Automapper for that, it seems quite similar to ValueInjector</description>
		<content:encoded><![CDATA[<p>Thanks for the hint! So far I&#8217;ve been using Automapper for that, it seems quite similar to ValueInjector</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Omu</title>
		<link>http://devermind.com/linq/aspnet-mvc-using-custom-viewmodels-with-post-action-methods/comment-page-1/#comment-562</link>
		<dc:creator>Omu</dc:creator>
		<pubDate>Fri, 11 Jun 2010 07:51:36 +0000</pubDate>
		<guid isPermaLink="false">http://devermind.com/?p=102#comment-562</guid>
		<description>you can use ValueInjecter http://valueinjecter.codeplex.com/ for mapping ViewModel to/from Entities, it&#039;s very good for this purpose</description>
		<content:encoded><![CDATA[<p>you can use ValueInjecter <a href="http://valueinjecter.codeplex.com/" rel="nofollow">http://valueinjecter.codeplex.com/</a> for mapping ViewModel to/from Entities, it&#8217;s very good for this purpose</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JBC</title>
		<link>http://devermind.com/linq/aspnet-mvc-using-custom-viewmodels-with-post-action-methods/comment-page-1/#comment-518</link>
		<dc:creator>JBC</dc:creator>
		<pubDate>Mon, 29 Mar 2010 19:10:10 +0000</pubDate>
		<guid isPermaLink="false">http://devermind.com/?p=102#comment-518</guid>
		<description>@Philippe: It doesnt appear as though youre setting your properties. Try this:

public class MeditationsFormModel : IFormModel
{
public Meditation Meditation { get; private set; }
public SelectList Types { get; private set; }


public MeditationsFormModel(Meditation meditation)
{
     Meditation  = meditation;
     Types = new SelectList( ::whatever your IEnumerable type is:: ,  ::whatever your selected value should be:: );
}
}</description>
		<content:encoded><![CDATA[<p>@Philippe: It doesnt appear as though youre setting your properties. Try this:</p>
<p>public class MeditationsFormModel : IFormModel<br />
{<br />
public Meditation Meditation { get; private set; }<br />
public SelectList Types { get; private set; }</p>
<p>public MeditationsFormModel(Meditation meditation)<br />
{<br />
     Meditation  = meditation;<br />
     Types = new SelectList( ::whatever your IEnumerable type is:: ,  ::whatever your selected value should be:: );<br />
}<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madonionmad</title>
		<link>http://devermind.com/linq/aspnet-mvc-using-custom-viewmodels-with-post-action-methods/comment-page-1/#comment-517</link>
		<dc:creator>madonionmad</dc:creator>
		<pubDate>Sun, 28 Mar 2010 16:03:06 +0000</pubDate>
		<guid isPermaLink="false">http://devermind.com/?p=102#comment-517</guid>
		<description>To Philippe:
Sorry, the code i post before invisible
you should use &quot;FirstName&quot; , not &quot;Custom.FirstName&quot;</description>
		<content:encoded><![CDATA[<p>To Philippe:<br />
Sorry, the code i post before invisible<br />
you should use &#8220;FirstName&#8221; , not &#8220;Custom.FirstName&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madonionmad</title>
		<link>http://devermind.com/linq/aspnet-mvc-using-custom-viewmodels-with-post-action-methods/comment-page-1/#comment-516</link>
		<dc:creator>madonionmad</dc:creator>
		<pubDate>Sun, 28 Mar 2010 16:00:04 +0000</pubDate>
		<guid isPermaLink="false">http://devermind.com/?p=102#comment-516</guid>
		<description>To Philippe:
      You should code like this:
       
      Not
      

     because the ViewModelBinder will bind the form to a object Customer, not CustomersFormViewModel.</description>
		<content:encoded><![CDATA[<p>To Philippe:<br />
      You should code like this:</p>
<p>      Not</p>
<p>     because the ViewModelBinder will bind the form to a object Customer, not CustomersFormViewModel.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adrian Grigore</title>
		<link>http://devermind.com/linq/aspnet-mvc-using-custom-viewmodels-with-post-action-methods/comment-page-1/#comment-508</link>
		<dc:creator>Adrian Grigore</dc:creator>
		<pubDate>Thu, 25 Feb 2010 11:27:39 +0000</pubDate>
		<guid isPermaLink="false">http://devermind.com/?p=102#comment-508</guid>
		<description>Sorry, I haven&#039;t had the time to have a look at MVC2&#039;s templates yet. I&#039;ve only just migrated my current MVC project to the MVC 2 codebase this week.</description>
		<content:encoded><![CDATA[<p>Sorry, I haven&#8217;t had the time to have a look at MVC2&#8217;s templates yet. I&#8217;ve only just migrated my current MVC project to the MVC 2 codebase this week.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben</title>
		<link>http://devermind.com/linq/aspnet-mvc-using-custom-viewmodels-with-post-action-methods/comment-page-1/#comment-507</link>
		<dc:creator>Ben</dc:creator>
		<pubDate>Thu, 25 Feb 2010 11:22:01 +0000</pubDate>
		<guid isPermaLink="false">http://devermind.com/?p=102#comment-507</guid>
		<description>I have found that Html.EditorForModel() doesn&#039;t work in this case; the SelectLists don&#039;t render. If I manually bind the SelectLists using Html.DropdownListFor, it does work. Have you found a way to use EditorForModel() in this case?</description>
		<content:encoded><![CDATA[<p>I have found that Html.EditorForModel() doesn&#8217;t work in this case; the SelectLists don&#8217;t render. If I manually bind the SelectLists using Html.DropdownListFor, it does work. Have you found a way to use EditorForModel() in this case?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Al Dass</title>
		<link>http://devermind.com/linq/aspnet-mvc-using-custom-viewmodels-with-post-action-methods/comment-page-1/#comment-501</link>
		<dc:creator>Al Dass</dc:creator>
		<pubDate>Wed, 10 Feb 2010 22:00:08 +0000</pubDate>
		<guid isPermaLink="false">http://devermind.com/?p=102#comment-501</guid>
		<description>FYI: 

That link to Phil&#039;s site in Adrian&#039;s previous post is invalid... here is the correct link:

&quot;Model Binding To A List&quot;
http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx</description>
		<content:encoded><![CDATA[<p>FYI: </p>
<p>That link to Phil&#8217;s site in Adrian&#8217;s previous post is invalid&#8230; here is the correct link:</p>
<p>&#8220;Model Binding To A List&#8221;<br />
<a href="http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx" rel="nofollow">http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
