<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : Silverlight 5 bug when saving twice in a row</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Silverlight 5 bug when saving twice in a row</description>
  <pubDate>Sat, 25 May 2013 05:05:01 -700</pubDate>
  <lastBuildDate>Wed, 11 Apr 2012 12:50:25 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=3374</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>Silverlight 5 bug when saving twice in a row :   Hi Maciej,I reproduced the...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3374&amp;PID=13283#13283</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=892" rel="nofollow">sbelini</a><br /><strong>Subject:</strong> 3374<br /><strong>Posted:</strong> 11-Apr-2012 at 12:50pm<br /><br />Hi Maciej,<div>&nbsp;</div><div>I reproduced the issue. The problem is that when you call:</div><div>&nbsp;</div><div><em>designSlotImage.Image.EntityAspect.Delete();</em></div><div>&nbsp;</div><div>The Image.EntityAspect.EntityState should change to Deleted rather then detached (i.e. assuming that the previous EntityState is Unchanged/Modified)</div><div>&nbsp;</div><div>I actually verified the issue in both SL4 and SL5. I'll be filing a bug for this.</div><div>&nbsp;</div><div>By the way, instead of checking:</div><div>&nbsp;</div><div><em>if (designSlotImage.ImageId != null)</em></div><div>&nbsp;</div><div>You should do:</div><div>&nbsp;</div><div><em>if (!designSlotImage.ImageId.EntityAspect.IsNullOrPendingEntity)</em></div><div>&nbsp;</div><div>You shouldn't rely on the FK having null value (while that might work for a Guid, it won't for an int)</div><div>&nbsp;</div><div>Silvio.</div>]]>
   </description>
   <pubDate>Wed, 11 Apr 2012 12:50:25 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3374&amp;PID=13283#13283</guid>
  </item> 
  <item>
   <title>Silverlight 5 bug when saving twice in a row : Hi Silvio,Of course my &amp;#039;Reproduce&amp;#039;...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3374&amp;PID=13278#13278</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1398" rel="nofollow">macgajos</a><br /><strong>Subject:</strong> 3374<br /><strong>Posted:</strong> 10-Apr-2012 at 11:10pm<br /><br />Hi Silvio,<div><br></div><div>Of course my 'Reproduce' sample is invalid, it was supposed to look like this:</div><div><br></div><div><div>SetDesignSlotImage(myDesignSlotImage, imageData, () =&gt;</div><div>{</div><div><span ="Apple-tab-span" style="white-space:pre">	</span>SetDesignSlotImage(myDesignSlotImage, imageData, () =&gt;{});</div><div>});</div></div><div><br></div><div>Sorry for confusion.</div><div><br></div><div>Regards,</div><div>Maciej</div>]]>
   </description>
   <pubDate>Tue, 10 Apr 2012 23:10:29 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3374&amp;PID=13278#13278</guid>
  </item> 
  <item>
   <title>Silverlight 5 bug when saving twice in a row :   Hi macgajos,This doesn&amp;#039;t...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3374&amp;PID=13257#13257</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=892" rel="nofollow">sbelini</a><br /><strong>Subject:</strong> 3374<br /><strong>Posted:</strong> 09-Apr-2012 at 4:16pm<br /><br />Hi macgajos,<div>&nbsp;</div><div>This doesn't seen like a bug.</div><div>&nbsp;</div><div>What is happening is that you are calling SetDesignSlotImage twice and the method itself performs a save (which occurs async). So the second time aroud, the entities still haven't been saved, but have already been modified.</div><div>&nbsp;</div><div>Your simplified code using NorthwindIB:</div><div>&nbsp;</div><div><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas">void</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas"> MainPage_Loaded(</font></font><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas">object</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas"> sender, </font></font><font color="#2b91af" size="2" face="C&#111;nsolas"><font color="#2b91af" size="2" face="C&#111;nsolas"><font color="#2b91af" size="2" face="C&#111;nsolas">RoutedEventArgs</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas"> e) {</font></font></div><div><font size="2"><font face="C&#111;nsolas">&nbsp; </font><font face="C&#111;nsolas">_mgr.Orders.AsScalarAsync().First(orderOp =&gt; {</font></font></div><div><font size="2" face="C&#111;nsolas">&nbsp;&nbsp;&nbsp; <font color="#0000ff"><font color="#0000ff"><font color="#0000ff">var</font></font></font> order = orderOp.Result;</font></div><div><font size="2" face="C&#111;nsolas">&nbsp;&nbsp;&nbsp; <font color="#0000ff"><font color="#0000ff"><font color="#0000ff">if</font></font></font> (order.EmployeeID != <font color="#0000ff"><font color="#0000ff"><font color="#0000ff">null</font></font></font>) {</font></div><div><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; order.Employee.EntityAspect.Delete();</font></font></div><div><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; order.Employee = </font></font><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas">null</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">;</font></font></div><div><font size="2"><font face="C&#111;nsolas">&nbsp;&nbsp;&nbsp; </font><font face="C&#111;nsolas">}</font></font></div><div>&nbsp;</div><div><font size="2" face="C&#111;nsolas">&nbsp;&nbsp;&nbsp; order.Employee = </font><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas">new</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas"> </font></font><font color="#2b91af" size="2" face="C&#111;nsolas"><font color="#2b91af" size="2" face="C&#111;nsolas"><font color="#2b91af" size="2" face="C&#111;nsolas">Employee</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">() { FirstName = </font></font><font color="#a31515" size="2" face="C&#111;nsolas"><font color="#a31515" size="2" face="C&#111;nsolas"><font color="#a31515" size="2" face="C&#111;nsolas">"Silvio1"</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">, LastName = </font></font><font color="#a31515" size="2" face="C&#111;nsolas"><font color="#a31515" size="2" face="C&#111;nsolas"><font color="#a31515" size="2" face="C&#111;nsolas">"Belini1"</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas"> };</font></font></div><div>&nbsp;</div><div><font size="2"><font face="C&#111;nsolas">&nbsp;&nbsp;&nbsp; </font><font face="C&#111;nsolas">_mgr.SaveChangesAsync(savedArgs1 =&gt; {</font></font></div><div><font size="2" face="C&#111;nsolas">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000ff"><font color="#0000ff"><font color="#0000ff">if</font></font></font> (savedArgs1.CompletedSuccessfully) {</font></div><div><font size="2" face="C&#111;nsolas">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#2b91af"><font color="#2b91af"><font color="#2b91af">MessageBox</font></font></font>.Show(<font color="#a31515"><font color="#a31515"><font color="#a31515">"saved ok"</font></font></font>);</font></div><div><font size="2"><font face="C&#111;nsolas">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font face="C&#111;nsolas">} </font></font><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas">else</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas"> {</font></font></div><div><font size="2" face="C&#111;nsolas">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#2b91af"><font color="#2b91af"><font color="#2b91af">MessageBox</font></font></font>.Show(savedArgs1.Exception.Message);</font></div><div><font size="2"><font face="C&#111;nsolas">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font face="C&#111;nsolas">}</font></font></div><div><font size="2" face="C&#111;nsolas">&nbsp;&nbsp;&nbsp; });</font></div><div>&nbsp;</div><div><font face="C&#111;nsolas"><font size="2">&nbsp;&nbsp;&nbsp; <font color="#008000"><font color="#008000"><font color="#008000">//&nbsp;second time around</font></font></font></font></font></div><div><font size="2" face="C&#111;nsolas"><font color="#008000"></font></font>&nbsp;</div><div><font size="2" face="C&#111;nsolas"><font color="#008000">&nbsp;&nbsp;&nbsp; </font><font color="#0000ff"><font color="#0000ff"><font color="#0000ff">if</font></font></font> (order.EmployeeID != <font color="#0000ff"><font color="#0000ff"><font color="#0000ff">null</font></font></font>) {</font></div><div><font size="2" face="C&#111;nsolas">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; o</font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">rder.Employee.EntityAspect.Delete();</font></font></div><div><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; order.Employee = </font></font><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas">null</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">;</font></font></div><div><font size="2"><font face="C&#111;nsolas">&nbsp;&nbsp;&nbsp; </font><font face="C&#111;nsolas">}</font></font></div><div><font size="2" face="C&#111;nsolas">&nbsp;&nbsp;&nbsp; order.Employee = </font><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas">new</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas"> </font></font><font color="#2b91af" size="2" face="C&#111;nsolas"><font color="#2b91af" size="2" face="C&#111;nsolas"><font color="#2b91af" size="2" face="C&#111;nsolas">Employee</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">() { FirstName = </font></font><font color="#a31515" size="2" face="C&#111;nsolas"><font color="#a31515" size="2" face="C&#111;nsolas"><font color="#a31515" size="2" face="C&#111;nsolas">"Silvio2"</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">, LastName = </font></font><font color="#a31515" size="2" face="C&#111;nsolas"><font color="#a31515" size="2" face="C&#111;nsolas"><font color="#a31515" size="2" face="C&#111;nsolas">"Belini2"</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas"> };</font></font></div><div><font size="2"><font face="C&#111;nsolas">&nbsp;&nbsp;&nbsp; </font><font face="C&#111;nsolas">_mgr.SaveChangesAsync(savedArgs2 =&gt; {</font></font></div><div><font size="2" face="C&#111;nsolas">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000ff"><font color="#0000ff"><font color="#0000ff">if</font></font></font> (savedArgs2.CompletedSuccessfully) {</font></div><div><font size="2" face="C&#111;nsolas">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#2b91af" size="2" face="C&#111;nsolas"><font color="#2b91af" size="2" face="C&#111;nsolas"><font color="#2b91af" size="2" face="C&#111;nsolas">MessageBox</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">.Show(</font></font><font color="#a31515" size="2" face="C&#111;nsolas"><font color="#a31515" size="2" face="C&#111;nsolas"><font color="#a31515" size="2" face="C&#111;nsolas">"saved ok"</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">);</font></font></div><div><font size="2"><font face="C&#111;nsolas">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font face="C&#111;nsolas">} </font></font><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas">else</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas"> {</font></font></div><div><font size="2" face="C&#111;nsolas">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#2b91af"><font color="#2b91af"><font color="#2b91af">MessageBox</font></font></font>.Show(savedArgs2.Exception.Message);</font></div><div><font size="2"><font face="C&#111;nsolas">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font face="C&#111;nsolas">}</font></font></div><div><font size="2" face="C&#111;nsolas">&nbsp;&nbsp;&nbsp; });</font></div><div><font size="2" face="C&#111;nsolas">&nbsp; });</font></div><div><font size="2" face="C&#111;nsolas">}</font></div><div>&nbsp;</div><div>What exactly are you trying to accomplish by modifying the same entity twice, the second time being while the first SaveChanges call is still pending?</div><div>&nbsp;</div><div>Regards,</div><div>&nbsp;&nbsp; Silvio.</div>]]>
   </description>
   <pubDate>Mon, 09 Apr 2012 16:16:54 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3374&amp;PID=13257#13257</guid>
  </item> 
  <item>
   <title>Silverlight 5 bug when saving twice in a row : Hi, I&amp;#039;ve found a bug in dev...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3374&amp;PID=13222#13222</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1398" rel="nofollow">macgajos</a><br /><strong>Subject:</strong> 3374<br /><strong>Posted:</strong> 04-Apr-2012 at 8:23am<br /><br />Hi, I've found a bug &nbsp;in dev force for Silverlight 5. Please find the following function:<div><br></div><div><div>public void SetDesignSlotImage(DesignSlotImage designSlotImage, byte&#091;&#093; imageData, Action callback)</div><div>{</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // imageData is != null</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (designSlotImage.ImageId != null)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; designSlotImage.Image.EntityAspect.Delete();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; designSlotImage.Image = null;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; designSlotImage.Image = new DomainModel.Image()</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ImageData = imageData,</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; };</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Breakpoint 1</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SaveChanges(myManager, () =&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Breakpoint 2</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; callback();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });</div><div>}</div><div><br></div><div>DesignSlotImage is a DB entity.&nbsp;</div><div>Image is a DB entity.</div><div>The relationship is 0..1 to &nbsp;many. Image has no navigation property for&nbsp;DesignSlotImage images.&nbsp;DesignSlotImage has nullable ImageId property and Image property.</div><div><br></div><div>If You run this method once, everything is ok. Unfortunately every two executions weird stuff happens:</div><div><br></div><div>Breakpoint 1&nbsp;</div><div>designSlotImage.Image &nbsp;is as it should be</div><div>Breakpoint 2&nbsp;</div><div>designSlotImage.Image is detached,&nbsp;designSlotImage.ImageID is ok</div><div><br></div><div>as a result , third execution of the method will not remove an Image.</div><div><br></div><div>Reproduce?</div><div>Run&nbsp;</div><div>SetDesignSlotImage(myDesignSlotImage, imageData, () =&gt;{});</div><div>SetDesignSlotImage(myDesignSlotImage, imageData, () =&gt;{});</div><div><br></div><div>Walkaround?</div><div>After saving changes manually assign image from cache:</div><div><div><br></div><div>SaveChanges(_persistenceGateway.LayoutsManager, () =&gt;</div><div>{</div></div><div><br></div><div><span ="Apple-tab-span" style="white-space:pre">	</span>designSlotImage.Image =&nbsp;</div><div><span ="Apple-tab-span" style="white-space:pre">		</span>myManager.Images.With(QueryStrategy.CacheOnly).First(p =&gt; p.Id == designSlotImage.ImageId);</div><div><br></div><div><span ="Apple-tab-span" style="white-space:pre">	</span>//Note that&nbsp;myManager.HasChanges returns false at this point&nbsp;</div><div><br></div><div><div><span ="Apple-tab-span" style="white-space:pre">	</span>callback();</div><div>});</div></div><div><br></div></div><div><br></div>]]>
   </description>
   <pubDate>Wed, 04 Apr 2012 08:23:19 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3374&amp;PID=13222#13222</guid>
  </item> 
 </channel>
</rss>