<?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 : Refresh Related Entity</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2009 : Refresh Related Entity</description>
  <pubDate>Thu, 21 May 2026 20:24:24 -700</pubDate>
  <lastBuildDate>Tue, 16 Mar 2010 14:01:24 -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=1664</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>Refresh Related Entity : Sorry, but there is much I don&amp;#039;t...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1664&amp;PID=6370#6370</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=21" rel="nofollow">IdeaBlade</a><br /><strong>Subject:</strong> 1664<br /><strong>Posted:</strong> 16-Mar-2010 at 2:01pm<br /><br />Sorry, but there is much I don't understand about your post. First of all, you refer to "setting up the Department Id in the Employee table," which sounds like some operation you're performing directly on a database table rather than in an object model. In the object model, there <EM>are </EM>no tables!&nbsp; <DIV>&nbsp;</DIV><DIV>Secondly, if you actually defined a relationship between the Employee and Department tables in the database, using Employee.DepartmentId as the foreign key to relate the two, then your object model would have been generated automatically with an association between the Employee and Department entities, and the Employee entity would not even <EM>have </EM>a DepartmentId property: it would only have a Department property. So I'm really not at all clear on what you're doing.&nbsp; I'm concerned that you may be misunderstanding the object model in some fundamental way, but I just can't yet tell exactly what it is that you're doing. </DIV><DIV>&nbsp;</DIV><DIV>So let's start with this question: &nbsp;Have you, in fact,&nbsp;defined a relationship in the database between Employee and Department, using Employee.DepartmentId as the foreign key that links to Department.DepartmentId?&nbsp; If not, why not?</DIV>]]>
   </description>
   <pubDate>Tue, 16 Mar 2010 14:01:24 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1664&amp;PID=6370#6370</guid>
  </item> 
  <item>
   <title>Refresh Related Entity :  I undertstands that it returns...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1664&amp;PID=6362#6362</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=632" rel="nofollow">ngoel</a><br /><strong>Subject:</strong> 1664<br /><strong>Posted:</strong> 15-Mar-2010 at 3:17pm<br /><br /><DIV>&nbsp;</DIV><DIV>I undertstands that it returns a Null Entity for Department if there isn't one available. My problem is when I am setting up the Department Id in the Employee table (Department Id is a Foriegn Key relating the Department table to the Employee Table), it is not updating the Null Entity to Actual Department. My question was is there a way to force an update. The way I am setting the Department Id is </DIV><DIV>&nbsp;</DIV><DIV><DIV>emp.DepartmentId = department.DepartmentId; ( According to the User Selection)</DIV><DIV>&nbsp;</DIV><DIV>It works if we already have a different department attached i.e. user is just changing the department, but it does not work when the Department attached to the Employee is a null entity. I hope I made myself clear this time.</DIV><DIV>&nbsp;</DIV><DIV>Thanks</DIV><DIV>Nitin</DIV></DIV>]]>
   </description>
   <pubDate>Mon, 15 Mar 2010 15:17:00 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1664&amp;PID=6362#6362</guid>
  </item> 
  <item>
   <title>Refresh Related Entity :  Originally posted by ngoel But...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1664&amp;PID=6338#6338</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=4" rel="nofollow">GregD</a><br /><strong>Subject:</strong> 1664<br /><strong>Posted:</strong> 09-Mar-2010 at 6:51pm<br /><br /><table width="99%"><tr><td class="BBquote"><strong><em>Originally posted by ngoel</strong></em><br /><br /><DIV>But I think when you create an Employee object with just the Primary Key values, it puts null entity for the Department. </DIV></td></tr></table> <DIV></DIV><DIV></DIV><DIV></DIV><DIV></DIV><DIV>&nbsp;</DIV><DIV>No, not really.&nbsp; When you first create the Employee object, the foreign key to Department is null. DevForce doesn't change that on its own.&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>However, if DevForce is asked to look up a Department with a foreign key of null (for example, when you reference <EM>newEmployee.Department</EM>), naturally it can't find one. DevForce could just let an exception be thrown: that's the standard .NET behavior when you refer to something that doesn't exist. But it likes to help you out; so instead of throwing an exception, it return a null entity for a Department. That way, your code doesn't blow up; but you (and your user) can still tell that there's no Department yet assigned.&nbsp; The foreign key remains null.</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV><table width="99%"><tr><td class="BBquote"><strong><em>Originally posted by ngoel</strong></em><br /><br /></DIV><DIV>I am doing, emp.DepartmentId = department.DepartmentId;</DIV></td></tr></table> <DIV></DIV><P>It does take some time to get used to not having to do all of the wiring via the foreign keys.</P>]]>
   </description>
   <pubDate>Tue, 09 Mar 2010 18:51:53 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1664&amp;PID=6338#6338</guid>
  </item> 
  <item>
   <title>Refresh Related Entity : Hello  Iam not assigning the...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1664&amp;PID=6334#6334</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=632" rel="nofollow">ngoel</a><br /><strong>Subject:</strong> 1664<br /><strong>Posted:</strong> 08-Mar-2010 at 7:09pm<br /><br /><DIV>Hello</DIV><DIV>&nbsp;</DIV><DIV>I&nbsp;am not assigning the null department entity to your Employee. But I think when you create an Employee object with just the Primary Key values, it puts null entity for the Department. For setting the Department value, I am doing it a bit differently. Here is my code:</DIV><DIV>&nbsp;</DIV><DIV>Employee emp = Employee.Create(_mgr);</DIV><DIV>Department department = GetSelectedDepartment();</DIV><DIV>&nbsp;</DIV><DIV>Now, instead of doing emp.Department = department;</DIV><DIV>&nbsp;</DIV><DIV>I am doing, emp.DepartmentId = department.DepartmentId;</DIV><DIV>&nbsp;</DIV><DIV>This way, the DepartmentId gets updated, but&nbsp;emp.Department.DepartmentId is still blank, which suggests that the Department object had not been updated. I think I have to manually update the department object.</DIV><DIV>&nbsp;</DIV><DIV>Thanks</DIV><DIV>Nitin</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Mon, 08 Mar 2010 19:09:30 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1664&amp;PID=6334#6334</guid>
  </item> 
  <item>
   <title>Refresh Related Entity :  I don&amp;#039;t quite get this....</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1664&amp;PID=6292#6292</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=21" rel="nofollow">IdeaBlade</a><br /><strong>Subject:</strong> 1664<br /><strong>Posted:</strong> 04-Mar-2010 at 2:14pm<br /><br />I don't quite get this. Presumably you aren't assigning the nulldepartment entity to your Employee; so I don't understand how theDepartment property of your Employee ends up being the null entity.<br><br>Isuspect that maybe there are some UI refresh issues involved in whatyou think you're seeing, though I can't quite figure out the scenario.But consider the following console app code:<br><br>&nbsp;&nbsp;&nbsp; private void DoIt() {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Customer aCustomer = _mgr.Customers.FirstOrNullEntity();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Order newOrder = Order.Create(_mgr);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine("New Order's Customer: {0}", newOrder.Customer.CompanyName);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newOrder.PropertyChanged += new syscomp.PropertyChangedEventHandler(newOrder_PropertyChanged);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newOrder.Customer = aCustomer;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine("New Order's Customer after assignment: {0}", newOrder.Customer.CompanyName);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PromptToContinue();<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; void newOrder_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine("Property changed on Order: {0}", e.PropertyName );<br>&nbsp;&nbsp;&nbsp; }<br><br>It produces the following output:<br><br><img src="uploads/21/_temp.jpg" height="133" width="544" border="0" /><br><br><br>]]>
   </description>
   <pubDate>Thu, 04 Mar 2010 14:14:34 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1664&amp;PID=6292#6292</guid>
  </item> 
  <item>
   <title>Refresh Related Entity : We have a Employee and Department...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1664&amp;PID=6272#6272</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=632" rel="nofollow">ngoel</a><br /><strong>Subject:</strong> 1664<br /><strong>Posted:</strong> 28-Feb-2010 at 8:01pm<br /><br /><P>We have a Employee and Department Many to One relationship where an employee is attached to single deparment. Employee table has DepartmentId as a Foriegn Key attached to the DepartmentId column in the Department table. When editing the employees, user change the DepartmentId and it automatically update the Department object attached to the Employee entity which is what I want.</P><P>But, when creating a new employee, I create a Employee with a Blank Department first and then update the DepartmentId on the Employee object according to the user selection. But this does not update the Department object attached. The Department Object attached is still a Null Entity. Is there a way to force an update on the Employee table so that it updates the department object according to the department id selected? I think we might have to detach the Department object and reattach it. But not sure how I do it. Can you help?</P>]]>
   </description>
   <pubDate>Sun, 28 Feb 2010 20:01:50 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1664&amp;PID=6272#6272</guid>
  </item> 
 </channel>
</rss>