<?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 : Inconsistencies saving entities</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Inconsistencies saving entities</description>
  <pubDate>Sun, 26 Apr 2026 21:23:57 -700</pubDate>
  <lastBuildDate>Mon, 21 Mar 2011 13:34:43 -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=2572</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>Inconsistencies saving entities : Hi c63205,   When you create...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2572&amp;PID=10235#10235</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> 2572<br /><strong>Posted:</strong> 21-Mar-2011 at 1:34pm<br /><br />Hi c63205, <DIV>&nbsp;</DIV><DIV>When you create a new entity its EntityState is Detached.</DIV><DIV>&nbsp;</DIV><DIV>If you 'link' this new Detached entity to an entity already attached to an EntityManager,&nbsp;(i.e. Added/Modified/Unchanged) the new entity will be automatically added to the EntityManager.</DIV><DIV>&nbsp;</DIV><DIV>i.e. </DIV><DIV><EM>var employee = mgr.Employees.First();</EM></DIV><DIV><EM></EM>&nbsp;</DIV><DIV><EM>Order newOrder = mgr.CreateEntity&lt;Order&gt;(); // newOrder.EntityAspect.EntityState == EntityState.Detached</EM></DIV><DIV><EM></EM>&nbsp;</DIV><DIV><EM>Order.Employee = employee; // newOrder.EntityAspect.EntityState == EntityState.Added</EM></DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>Note that the above will NOT happen if both entities are not attached to an EntityManager.</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>I suggest to always explicitly add the entity to an EntityManager.</DIV><DIV>&nbsp;</DIV><DIV>Regards,</DIV><DIV>&nbsp;&nbsp; Silvio.</DIV>]]>
   </description>
   <pubDate>Mon, 21 Mar 2011 13:34:43 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2572&amp;PID=10235#10235</guid>
  </item> 
  <item>
   <title>Inconsistencies saving entities : I&amp;#039;d appreciate anyguidancewith...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2572&amp;PID=10229#10229</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1037" rel="nofollow">c63205</a><br /><strong>Subject:</strong> 2572<br /><strong>Posted:</strong> 21-Mar-2011 at 10:08am<br /><br /><DIV>I'd appreciate any&nbsp;guidance&nbsp;with this issue.&nbsp; It involves creating entities and having inconsistent entity states: Detached and Added.&nbsp; Also, sometimes the new&nbsp;entities are not persisted to the DB.&nbsp; Oddly, this behavior only seems to have occurred recently. </DIV><DIV>&nbsp;</DIV><DIV>I've just recently started developing with devforce and so far, I create my entities with the code:</DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas><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><P>MasterQuestion</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> mq = appUtil.Manager.CreateEntity&lt;</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>MasterQuestion</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&gt;();</P></FONT></FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas><DIV></DIV><DIV></DIV><DIV> It appeared that sometimes the new entity would have the 'Added' state, and at other places an entity would be in the 'Detached' state.</DIV><DIV>&nbsp;</DIV><DIV>So far, I have NOT also included the AddEntity() line when creating new entities like so:&nbsp; ...is this correct?&nbsp; Why would I have been experiencing inconsistent results.</DIV><DIV>&nbsp;</DIV><DIV><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><P>MasterQuestion</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> mq = appUtil.Manager.CreateEntity&lt;</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>MasterQuestion</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&gt;();</P><P>mq.ID = </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>Guid</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>.NewGuid();</P><P>appUtil.Manager.AddEntity(mq);</P></FONT></FONT></FONT></FONT></DIV>]]>
   </description>
   <pubDate>Mon, 21 Mar 2011 10:08:10 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2572&amp;PID=10229#10229</guid>
  </item> 
 </channel>
</rss>