<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>ASP.NET MVC Storefront Starter Kit</title><link>http://forums.asp.net/1165.aspx</link><description>This forum is for any and all questions pertaining to the ASP.NET MVC Storefront Starter Kit. The Storefront  is a sample ASP.NET MVC Commerce application which was developed using Test-driven Development, Inversion of Control (IoC), and Dependency Injection.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Avoiding duplicate domain objects</title><link>http://forums.asp.net/thread/2950669.aspx</link><pubDate>Thu, 19 Feb 2009 00:06:38 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2950669</guid><dc:creator>Paul Linton</dc:creator><author>Paul Linton</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2950669.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1165&amp;PostID=2950669</wfw:commentRss><description>&lt;p&gt;I guess overriding Equals() and Hashcode() would make that particular test pass but I wouldn&amp;#39;t really have the same object, I would just have two objects which happen to have the same properites.&amp;nbsp; Maybe, I have the wrong test - let me try again.&lt;/p&gt;&lt;pre class="coloredcode"&gt;[TestMethod]
&lt;span class="kwd"&gt;public void&lt;/span&gt; Order_shouldHave_Constant_Identity()
{
   OrderProcessing.Order order1 = orderRepository
                                  .GetOrders()
                                  .Where(o=&amp;gt;o.OrderID == 1)
                                  .SingleOrDefault();
   order1.BillingAddress = &lt;span class="kwd"&gt;new&lt;/span&gt; Address() {Country=&lt;span class="st"&gt;&amp;quot;Australia&amp;quot;&lt;/span&gt;};
   OrderProcessing.Order order2 = orderRepository
                                  .GetOrders()
                                  .Where(o=&amp;gt;0.OrderID == 1)
                                  .SingleOrDefault();&lt;/pre&gt;&lt;pre class="coloredcode"&gt;   order2.BillingAddress = new Address() { Country = &amp;quot;USA&amp;quot;} ;
   Assert.AreEqual(order1.BillingAddress.Country, order2.BillingAdress.Country, &lt;span class="st"&gt;&amp;quot;Getting the same order twice should return the same object&amp;quot;&lt;/span&gt;);
}
&lt;/pre&gt;
&lt;p&gt;This&amp;nbsp;object identity problem is looked after by LinqToSql for the objects that are&amp;nbsp;created as a result of retrieving&amp;nbsp;database rows. &lt;a href="http://msdn.microsoft.com/en-us/library/bb399376.aspx"&gt;http://msdn.microsoft.com/en-us/library/bb399376.aspx&lt;/a&gt;&amp;nbsp;but I don&amp;#39;t know how to enforce the same logic for my domain objects.&lt;/p&gt;</description></item><item><title>Re: Avoiding duplicate domain objects</title><link>http://forums.asp.net/thread/2950655.aspx</link><pubDate>Wed, 18 Feb 2009 23:52:31 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2950655</guid><dc:creator>robconery</dc:creator><author>robconery</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2950655.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1165&amp;PostID=2950655</wfw:commentRss><description>&lt;p&gt;Have you tried to override Equals() and Hashcode?&lt;/p&gt;</description></item><item><title>Avoiding duplicate domain objects</title><link>http://forums.asp.net/thread/2950595.aspx</link><pubDate>Wed, 18 Feb 2009 22:53:50 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2950595</guid><dc:creator>Paul Linton</dc:creator><author>Paul Linton</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2950595.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1165&amp;PostID=2950595</wfw:commentRss><description>&lt;p&gt;I have looked very closely at the screen shots in the last few storefront episodes (since Rob contracted a mild case of DDD fever).&amp;nbsp; I have modeled my own application repositry very closely on the one I see in the screenshots.&amp;nbsp; I have written a test which fails and I don&amp;#39;t know how to go about fixing the problem. Any suggestions would be welcomed.&lt;/p&gt;
&lt;p&gt;Using the SqlOrderRepository as an example I could write a test something like this&lt;/p&gt;&lt;pre class="coloredcode"&gt;[TestMethod]
&lt;span class="kwd"&gt;public void&lt;/span&gt; Order_shouldHave_Constant_Identity()
{
   OrderProcessing.Order order1 = orderRepository
                                  .GetOrders()
                                  .Where(o=&amp;gt;o.OrderID == 1)
                                  .SingleOrDefault();
   OrderProcessing.Order order2 = orderRepository
                                  .GetOrders()
                                  .Where(o=&amp;gt;0.OrderID == 1)
                                  .SingleOrDefault();
   Assert.AreSame(order1, order2, &lt;span class="st"&gt;&amp;quot;Getting the same order twice should return the same object&amp;quot;&lt;/span&gt;);
}
&lt;/pre&gt;
&lt;p&gt;Note that I attempt to retrieve the same OrderId both times.&amp;nbsp; The Assert.AreSame fails as the two objects are not the same.&amp;nbsp; This obviously opens the door to all sorts of nasty things happening.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m guessing that I need to introduce some kind of identity map for the domain objects but I don&amp;#39;t know how to go about it.&amp;nbsp; Any suggestions?&amp;nbsp; (Hey Rob, an answer of &amp;#39;Wait until after MIX, all will be revealed&amp;quot; would do for me)&lt;/p&gt;
&lt;p&gt;thanks for any help&lt;/p&gt;</description></item></channel></rss>