<?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 : NullEntity in a list</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : NullEntity in a list</description>
  <pubDate>Sat, 11 Apr 2026 17:54:14 -700</pubDate>
  <lastBuildDate>Thu, 07 Oct 2010 12:58:50 -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=2218</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>NullEntity in a list : Chuck,  In the situation above...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2218&amp;PID=8744#8744</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> 2218<br /><strong>Posted:</strong> 07-Oct-2010 at 12:58pm<br /><br />Chuck,<DIV>&nbsp;</DIV><DIV>In the situation above the null entity should not be added to the Contact.Users list.</DIV><DIV>I am filing a bug for this issue.</DIV><DIV>&nbsp;</DIV><DIV>As for the comment where subsequent attempts do not except, it's because you are trying to&nbsp;relate the same nullUser to the contact&nbsp;twice, so it doesn't even try to add the null entity the second time.</DIV>]]>
   </description>
   <pubDate>Thu, 07 Oct 2010 12:58:50 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2218&amp;PID=8744#8744</guid>
  </item> 
  <item>
   <title>NullEntity in a list : I am seeing some unexpected behavior...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2218&amp;PID=8734#8734</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=705" rel="nofollow">chuckc</a><br /><strong>Subject:</strong> 2218<br /><strong>Posted:</strong> 06-Oct-2010 at 2:17pm<br /><br /><p ="Ms&#111;normal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal;mso-layout-grid-align:n&#111;ne;text-autospace:n&#111;ne"><span style="font-size:  9.5pt;font-family:C&#111;nsolas"><o:p><br></o:p></span></p><p ="Ms&#111;normal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal;mso-layout-grid-align:n&#111;ne;text-autospace:n&#111;ne"><o:p><font ="Apple-style-span" face="Arial, Helvetica, sans-serif"><span ="Apple-style-span" style="font-size: small;">I am seeing some unexpected behavior regarding NullEntity. &nbsp;Is this a bug? &nbsp;Can NullEntities be added to lists as shown, or is that intrinsically not possible?</span></font></o:p></p><p ="Ms&#111;normal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal;mso-layout-grid-align:n&#111;ne;text-autospace:n&#111;ne"><o:p><font ="Apple-style-span" face="Arial, Helvetica, sans-serif"><span ="Apple-style-span" style="font-size: small;">Thanks!</span></font></o:p></p><p ="Ms&#111;normal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal;mso-layout-grid-align:n&#111;ne;text-autospace:n&#111;ne"><o:p><font ="Apple-style-span" face="Arial, Helvetica, sans-serif"><span ="Apple-style-span" style="font-size: small;"><br></span></font></o:p></p><p ="Ms&#111;normal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal;mso-layout-grid-align:n&#111;ne;text-autospace:n&#111;ne"><span style="font-size:  9.5pt;font-family:C&#111;nsolas;color:#2B91AF">Contact</span><span style="font-size:  9.5pt;font-family:C&#111;nsolas"> contact = EntityManager.Contacts.FirstOrDefault();<br></span><span style="font-size:  9.5pt;font-family:C&#111;nsolas;color:#2B91AF">User</span><span style="font-size:  9.5pt;font-family:C&#111;nsolas"> nullUser = EntityManager.GetNullEntity&lt;<span style="color:#2B91AF">User</span>&gt;();</span></p><p ="Ms&#111;normal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal;mso-layout-grid-align:n&#111;ne;text-autospace:n&#111;ne"><span ="Apple-style-span" style="font-family: C&#111;nsolas; font-size: 13px; color: rgb0, 0, 255; ">try<br></span><span ="Apple-style-span" style="font-family: C&#111;nsolas; font-size: 13px; ">{<br></span><span ="Apple-style-span" style="font-family: C&#111;nsolas; font-size: 13px; color: rgb0, 128, 0; "><span style="mso-spacerun:yes">&nbsp;&nbsp;&nbsp;</span>// At this point, contact.Users.Count == 0<br></span><span ="Apple-style-span" style="font-family: C&#111;nsolas; font-size: 13px; "><span style="mso-spacerun:yes">&nbsp;&nbsp;&nbsp;</span>contact.Users.Add(nullUser);<br></span><span ="Apple-style-span" style="font-family: C&#111;nsolas; font-size: 13px; ">}<br></span><span style="font-size:  9.5pt;font-family:C&#111;nsolas;color:blue">catch</span><span style="font-size:9.5pt;  font-family:C&#111;nsolas"> (<span style="color:#2B91AF">Exception</span> e1)<br></span><span ="Apple-style-span" style="font-family: C&#111;nsolas; font-size: 13px; ">{<br></span><span ="Apple-style-span" style="font-family: C&#111;nsolas; font-size: 13px; color: rgb0, 128, 0; "><span style="mso-spacerun:yes">&nbsp;&nbsp;&nbsp;</span>// Excepts with "Null or pending entities cannot be modified"- presumably because adding<br></span><span ="Apple-style-span" style="font-family: C&#111;nsolas; font-size: 13px; color: rgb0, 128, 0; "><span style="mso-spacerun:yes">&nbsp;&nbsp;&nbsp;</span>// the nullUser to the list contact.Users is internally trying to set anassociation key on nullUser.</span></p><p ="Ms&#111;normal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal;mso-layout-grid-align:n&#111;ne;text-autospace:n&#111;ne"><span ="Apple-style-span" style="font-family: C&#111;nsolas; font-size: 13px; color: rgb0, 128, 0; "><span style="mso-spacerun:yes">&nbsp;&nbsp;&nbsp;</span>// However, the nullUser is actually added to the Users list.<br></span><span ="Apple-style-span" style="font-family: C&#111;nsolas; font-size: 13px; color: rgb0, 128, 0; "><span style="mso-spacerun:yes">&nbsp;&nbsp;&nbsp;</span>// contact.Users.Count is now 1</span></p><p ="Ms&#111;normal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal;mso-layout-grid-align:n&#111;ne;text-autospace:n&#111;ne"><span style="font-size:  9.5pt;font-family:C&#111;nsolas;color:blue"><span style="mso-spacerun:yes">&nbsp;&nbsp;&nbsp;</span>bool</span><span style="font-size:9.5pt;font-family:C&#111;nsolas"> wtf = <span style="color:blue">false</span>;<br></span><span ="Apple-style-span" style="font-family: C&#111;nsolas; font-size: 13px; ">}</span></p><p ="Ms&#111;normal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal;mso-layout-grid-align:n&#111;ne;text-autospace:n&#111;ne"><span ="Apple-style-span" style="font-family: C&#111;nsolas; font-size: 13px; color: rgb0, 128, 0; ">// Due to some odd behavior I wasseeing elsewhere, I noticed that subsequent attempts do *not* except!<br></span><span ="Apple-style-span" style="font-family: C&#111;nsolas; font-size: 13px; color: rgb0, 128, 0; ">// Perhaps that is because the nullUseris already in the list?<br></span><span ="Apple-style-span" style="font-family: C&#111;nsolas; font-size: 13px; color: rgb0, 0, 255; ">try<br></span><span ="Apple-style-span" style="font-family: C&#111;nsolas; font-size: 13px; ">{<br></span><span ="Apple-style-span" style="font-family: C&#111;nsolas; font-size: 13px; "><span style="mso-spacerun:yes">&nbsp;&nbsp;&nbsp;</span>contact.Users.Add(nullUser);<br></span><span ="Apple-style-span" style="font-family: C&#111;nsolas; font-size: 13px; ">}<br></span><span style="font-size:  9.5pt;font-family:C&#111;nsolas;color:blue">catch</span><span style="font-size:9.5pt;  font-family:C&#111;nsolas"> (<span style="color:#2B91AF">Exception</span> e2)<br></span><span ="Apple-style-span" style="font-family: C&#111;nsolas; font-size: 13px; ">{<br></span><span ="Apple-style-span" style="font-family: C&#111;nsolas; font-size: 13px; color: rgb0, 128, 0; "><span style="mso-spacerun:yes">&nbsp;&nbsp;</span><span style="mso-spacerun:yes">&nbsp;</span>// Does not except on secondattempt!<br></span><span style="font-size:  9.5pt;font-family:C&#111;nsolas;color:blue"><span style="mso-spacerun:yes">&nbsp;&nbsp;&nbsp;</span>bool</span><span style="font-size:9.5pt;font-family:C&#111;nsolas"> wtf = <span style="color:blue">true</span>;<br></span><span ="Apple-style-span" style="font-family: C&#111;nsolas; font-size: 13px; ">}</span></p><p ="Ms&#111;normal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal;mso-layout-grid-align:n&#111;ne;text-autospace:n&#111;ne"><span style="font-size:  9.5pt;font-family:C&#111;nsolas"><o:p>&nbsp;</o:p></span></p><p ="Ms&#111;normal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal;mso-layout-grid-align:n&#111;ne;text-autospace:n&#111;ne"><span style="font-size:  9.5pt;font-family:C&#111;nsolas"><o:p>&nbsp;</o:p></span></p>]]>
   </description>
   <pubDate>Wed, 06 Oct 2010 14:17:37 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2218&amp;PID=8734#8734</guid>
  </item> 
 </channel>
</rss>