<?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 : Foreign Key Questions</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2009 : Foreign Key Questions</description>
  <pubDate>Sat, 11 Apr 2026 03:13:20 -700</pubDate>
  <lastBuildDate>Sun, 28 Jun 2009 07:20:00 -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=1293</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>Foreign Key Questions : Check if FK &amp;gt; 0 is not really...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1293&amp;PID=4870#4870</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=412" rel="nofollow">Amy</a><br /><strong>Subject:</strong> 1293<br /><strong>Posted:</strong> 28-Jun-2009 at 7:20am<br /><br />Check if FK &gt; 0 is not really working. When adding parent, also adding related children in the same time, the FKs for children&nbsp; are negative. <DIV>&nbsp;</DIV><DIV>Amy</DIV>]]>
   </description>
   <pubDate>Sun, 28 Jun 2009 07:20:00 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1293&amp;PID=4870#4870</guid>
  </item> 
  <item>
   <title>Foreign Key Questions : Hi Jeff,    I am interested...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1293&amp;PID=4843#4843</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=412" rel="nofollow">Amy</a><br /><strong>Subject:</strong> 1293<br /><strong>Posted:</strong> 24-Jun-2009 at 9:28am<br /><br />Hi Jeff, <DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>I am&nbsp; interested in the code. Please post it whenever you have time. </DIV><DIV>&nbsp;</DIV><DIV>Thank you very much!</DIV><DIV>&nbsp;</DIV><DIV>Amy</DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Wed, 24 Jun 2009 09:28:08 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1293&amp;PID=4843#4843</guid>
  </item> 
  <item>
   <title>Foreign Key Questions : I haven&amp;#039;t done this for EF...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1293&amp;PID=4808#4808</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=34" rel="nofollow">jeffdoolittle</a><br /><strong>Subject:</strong> 1293<br /><strong>Posted:</strong> 18-Jun-2009 at 8:50pm<br /><br />I haven't done this for EF yet, but in DevForce classic, I took a different approach that worked really well for discovering potential FK violations prior to saving to the database.<br><br>1) I created an algorithm that looks at all EntityRelations and discovers all relations where the parent entity is required.&nbsp; This process discovers the parent property descriptor for the parent relation and looks for the "RequiredValueVerifierAttribute" on that property.&nbsp; It's a bit complex, but it works great for discovering the parent required properties.<br><br>2) I created a "NotNullEntityVerifier" that fails if an entity is the null entity.<br><br>3) I created a helper method that, when given an entity type, adds a NotNullEntityVerifier to the VerifierEngine for all required parent properties of the given type.<br><br>When all is said and done, all I have to do is go to my GetVerifiers static method for an entity type and do this:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#091;VerifierProvider&#093;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public static IEnumerable&lt;Verifier&gt; GetVerifiers(Object pVerifierProviderContext)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var engine = GetEngineFromVerifierProviderContext(pVerifierProviderContext);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var list = new List&lt;Verifier&gt;();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; list.AddParentRequiredVerifiers&lt;Employee&gt;();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return list;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>If you are so inclined, you could even call this method for all entity types in your Model assembly all at once rather than calling this once for each entity type (though in a large model this may not be advisable).<br><br>It's almost like magic when your Foreign Keys are enforced completely in the middle tier.<br><br>If any one is interested in the code, post on this thread and I'll try to find time to clean up and add this code to the DevForceContrib project on CodePlex (http://devforcecontrib.codeplex.com/).<br><br><br>--Jeff<br>]]>
   </description>
   <pubDate>Thu, 18 Jun 2009 20:50:32 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1293&amp;PID=4808#4808</guid>
  </item> 
  <item>
   <title>Foreign Key Questions : What is your rule for &amp;#034;Required...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1293&amp;PID=4805#4805</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=51" rel="nofollow">eileenv</a><br /><strong>Subject:</strong> 1293<br /><strong>Posted:</strong> 18-Jun-2009 at 2:39pm<br /><br /><P>What is your rule for "Required FKs"? Is it that the value must be greater than 0? If the FKs are not nullable ints, then you would need some numeric rule for determining whether or not the FK is valid.</P><P>Here is how to write a verifier that says "ID must be greater than 0":</P><DIV><DIV><FONT color=#0000ff size=2><FONT color=#0000ff size=2>private</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>static</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Verifier</FONT></FONT><FONT size=2> GetOperationIDRequiredVerifier() { </FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp; <FONT color=#0000ff><FONT color=#0000ff>return</FONT></FONT> <FONT color=#0000ff><FONT color=#0000ff>new</FONT></FONT> <FONT color=#2b91af><FONT color=#2b91af>Int32RangeVerifier</FONT></FONT>(</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#0000ff><FONT color=#0000ff>typeof</FONT></FONT>(<FONT color=#2b91af><FONT color=#2b91af>Vehicle</FONT></FONT>), <FONT color=#2b91af><FONT color=#2b91af>Vehicle</FONT></FONT>.Operation_fk_OperationIDEntityProperty.Name, </FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#0000ff><FONT color=#0000ff>true</FONT></FONT>, </FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // minValue = 0</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#0000ff>false,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;do not include the minEndpoint&nbsp;&nbsp; </FONT></FONT></DIV><DIV><FONT size=2><FONT color=#0000ff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; null,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // don't care about maxValue</FONT></FONT></DIV><DIV><FONT size=2><FONT color=#0000ff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; false</FONT>);&nbsp;&nbsp;&nbsp; // do not include the maxEndpoint</FONT></DIV><DIV><FONT size=2>}</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV>The problem with the original verifier you wrote is that you were basically saying that any ID from 0 to the maximum integer value is OK and valid.</DIV></DIV>]]>
   </description>
   <pubDate>Thu, 18 Jun 2009 14:39:06 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1293&amp;PID=4805#4805</guid>
  </item> 
  <item>
   <title>Foreign Key Questions : #1 I mentioned inmy question:...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1293&amp;PID=4691#4691</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=412" rel="nofollow">Amy</a><br /><strong>Subject:</strong> 1293<br /><strong>Posted:</strong> 02-Jun-2009 at 11:19am<br /><br />#1&nbsp;&nbsp; I mentioned in&nbsp;my question: I did add a range verifier, but it returns OK. Is anything wrong with following code?<DIV><FONT color=#0000ff size=2><FONT color=#0000ff size=2></FONT></FONT>&nbsp;</DIV><DIV><FONT color=#0000ff size=2><FONT color=#0000ff size=2>private</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>static</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Verifier</FONT></FONT><FONT size=2> GetOperationIDRequiredVerifier()</DIV><P>{ </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>return</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Int32RangeVerifier</FONT></FONT><FONT size=2>(</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>typeof</FONT></FONT><FONT size=2>(</FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Vehicle</FONT></FONT><FONT size=2>), </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Vehicle</FONT></FONT><FONT size=2>.Operation_fk_OperationIDEntityProperty.Name,</P><P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>true</FONT></FONT><FONT size=2>, 0, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>int</FONT></FONT><FONT size=2>.MaxValue);</FONT><FONT size=2>}</P><DIV></DIV>#2 We also added an NullEntity on each non-requied FK. Since we have&nbsp; a lot FKs,&nbsp; wish there is a better solution.<DIV></DIV><DIV></DIV><DIV></DIV><DIV></DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>Thanks!</DIV></FONT>]]>
   </description>
   <pubDate>Tue, 02 Jun 2009 11:19:45 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1293&amp;PID=4691#4691</guid>
  </item> 
  <item>
   <title>Foreign Key Questions : For answers and tips on writing...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1293&amp;PID=4689#4689</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=23" rel="nofollow">davidklitzke</a><br /><strong>Subject:</strong> 1293<br /><strong>Posted:</strong> 02-Jun-2009 at 8:13am<br /><br /><P>For answers and tips on writing your own verifiers, see the Intermediate tutorial on "Verification".</P><DIV>For an example of the use of a combobox that uses the Null Entity, see the Intermediate tutorial on "Working with ComboBoxes".&nbsp; In this tutorial, a Null Entity is used to indicate that an Employee has no Manager.</DIV>]]>
   </description>
   <pubDate>Tue, 02 Jun 2009 08:13:31 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1293&amp;PID=4689#4689</guid>
  </item> 
  <item>
   <title>Foreign Key Questions : Our database has a lot FKs that...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1293&amp;PID=4685#4685</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=412" rel="nofollow">Amy</a><br /><strong>Subject:</strong> 1293<br /><strong>Posted:</strong> 01-Jun-2009 at 9:45am<br /><br /><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Verdana; mso-ansi-: EN">Our database has a lot FKs that are integers. Some of them are required filed, some of them are not. <SPAN style="mso-spacerun: yes">&nbsp;</SPAN>I have some questions:<?: prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Verdana; mso-ansi-: EN"><o:p>&nbsp;</o:p></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1; tab-stops: list .5in"><SPAN lang=EN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Verdana; mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana; mso-ansi-: EN"><SPAN style="mso-list: Ignore">1.<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><SPAN lang=EN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Verdana; mso-ansi-: EN">For required FK,<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>how do you write your own verifier? DevForce’s default verifier for required FK is always returns OK, no matter what. I tried to write a range verifier for the required FK, it always returns OK too. <SPAN style="mso-spacerun: yes">&nbsp;&nbsp;</SPAN>How do you enforce the required FK?<o:p></o:p></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1; tab-stops: list .5in"><SPAN lang=EN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Verdana; mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana; mso-ansi-: EN"><SPAN style="mso-list: Ignore">2.<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><SPAN lang=EN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Verdana; mso-ansi-: EN">In edit screen, how do you fill the ComboBox of non-required FK? Add a null entity? Since it is not required, the user should be able to change the ComboBox to select nothing. <o:p></o:p></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Verdana; mso-ansi-: EN"><o:p>&nbsp;</o:p></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Verdana; mso-ansi-: EN">Any help/suggestion would be appreciated.<o:p></o:p></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Verdana; mso-ansi-: EN"><o:p>&nbsp;</o:p></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Verdana; mso-ansi-: EN"><o:p>&nbsp;</o:p></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Verdana; mso-ansi-: EN">Thanks!<o:p></o:p></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Verdana; mso-ansi-: EN"><o:p>&nbsp;</o:p></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Verdana; mso-ansi-: EN">Amy<o:p></o:p></SPAN></P>]]>
   </description>
   <pubDate>Mon, 01 Jun 2009 09:45:54 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1293&amp;PID=4685#4685</guid>
  </item> 
 </channel>
</rss>