<?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 : Working with Composite Keys</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce Classic : Working with Composite Keys</description>
  <pubDate>Sat, 11 Apr 2026 13:46:13 -700</pubDate>
  <lastBuildDate>Wed, 30 May 2007 17:26:38 -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=23</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>Working with Composite Keys : DevForce supports the use of composite...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=23&amp;PID=78#78</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> 23<br /><strong>Posted:</strong> 30-May-2007 at 5:26pm<br /><br /><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><FONT face="Arial, Helvetica, sans-serif" size=2>DevForce supports the use of composite keys, and we have many customers who use this strategy.&nbsp; Furthermore, we never (or at least <I style="mso-bidi-font-style: normal">almost</I> never)&nbsp;tell our customers that they need to redesign their database.</FONT></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><FONT size=2><FONT face="Arial, Helvetica, sans-serif">For our own work, we prefer single-part keys (when we have the option of choosing the key type) --<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>simply because they are more convenient to work with than composite keys. For that matter, we also prefer “artificial” keys – those with no meaningful connection to the other information in their record.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>That avoids many problems that occur when factors external to the database force that other information to change.<SPAN style="FONT-FAMILY: C&#111;nsolas"><?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></FONT></FONT></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><FONT face="Arial, Helvetica, sans-serif" size=2>To make your code work with a composite key, you would simply add additional clauses to the query to specify the value of the remaining column(s) that participate in the key.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>For example, immediately following the statement where you instantiate the query, and before using that query in the GetEntity() method call, you could add a statement like the following:<BR style="mso-special-character: line-break"><BR style="mso-special-character: line-break"></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB style="mso-ansi-: EN-GB"><strong><FONT size=2><FONT color=#808080><FONT style=": #e6e6e6"><FONT face="Courier New, Courier, mono"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>empQ.AddClause(Employee.IdPart2EntityColumn, EntityQueryOp.EQ, idPart2);</P><DIV></DIV><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><o:p></o:p></FONT></FONT></FONT></FONT></strong></SPAN></P>]]>
   </description>
   <pubDate>Wed, 30 May 2007 17:26:38 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=23&amp;PID=78#78</guid>
  </item> 
  <item>
   <title>Working with Composite Keys : The Developers Guide says: &#8220;Most...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=23&amp;PID=74#74</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=20" rel="nofollow">Customer</a><br /><strong>Subject:</strong> 23<br /><strong>Posted:</strong> 30-May-2007 at 4:52pm<br /><br /><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><SPAN lang=EN-GB style="mso-ansi-: EN-GB"><FONT size=2><FONT face="Times New Roman">The Developers Guide says:<?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></FONT></FONT></SPAN></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><FONT face="Times New Roman" size=2>“Most of the time an object’s key consists of a single identifier and so the words “key” and “identifier” are used interchangeably. Multipart keys are possible and sometimes necessary but we prefer single part keys.”</FONT></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><FONT size=2><FONT face="Times New Roman"><SPAN lang=EN-GB style="mso-ansi-: EN-GB">How do you accommodate those in DevForce?<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>For example, h</SPAN>ow would you do the equivalent of the following for Employee object with a composite key?</FONT></FONT></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><o:p><FONT face="Times New Roman" size=2>&nbsp;</FONT></o:p></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB style="mso-ansi-: EN-GB"><FONT size=2><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&#091;DataObjectMethod(DataObjectMethodType.Select)&#093;<o:p></o:p></FONT></strong></FONT></FONT></FONT></SPAN></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT size=2><FONT style=": #e6e6e6"><strong><FONT face="Courier New"><SPAN lang=EN-GB style="mso-ansi-: EN-GB"><FONT color=#808080>&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN lang=EN-GB style="COLOR: blue; mso-ansi-: EN-GB">public</SPAN><SPAN lang=EN-GB style="mso-ansi-: EN-GB"><FONT color=#808080> BindableList&lt;Employee&gt; GetSelectedEmployee(</FONT></SPAN><SPAN lang=EN-GB style="COLOR: blue; mso-ansi-: EN-GB">string</SPAN><SPAN lang=EN-GB style="mso-ansi-: EN-GB"><FONT color=#808080> sort, Int64 id) {<o:p></o:p></FONT></SPAN></FONT></strong></FONT></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT size=2><FONT style=": #e6e6e6"><strong><FONT face="Courier New"><SPAN lang=EN-GB style="mso-ansi-: EN-GB"><FONT color=#808080>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EntityQuery empQ = </FONT></SPAN><SPAN lang=EN-GB style="COLOR: blue; mso-ansi-: EN-GB">new</SPAN><SPAN lang=EN-GB style="mso-ansi-: EN-GB"><FONT color=#808080> EntityQuery(</FONT></SPAN><SPAN lang=EN-GB style="COLOR: blue; mso-ansi-: EN-GB">typeof</SPAN><SPAN lang=EN-GB style="mso-ansi-: EN-GB"><FONT color=#808080>(Employee), Employee.IdEntityColumn, EntityQueryOp.EQ, id);<o:p></o:p></FONT></SPAN></FONT></strong></FONT></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT size=2><FONT style=": #e6e6e6"><strong><FONT face="Courier New"><SPAN lang=EN-GB style="mso-ansi-: EN-GB"><FONT color=#808080>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Employee emp = </FONT></SPAN><SPAN lang=EN-GB style="COLOR: blue; mso-ansi-: EN-GB">this</SPAN><SPAN lang=EN-GB style="mso-ansi-: EN-GB"><FONT color=#808080>.PersistenceManager.GetEntity&lt;Employee&gt;(empQ);<o:p></o:p></FONT></SPAN></FONT></strong></FONT></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT size=2><FONT style=": #e6e6e6"><strong><FONT face="Courier New"><SPAN lang=EN-GB style="mso-ansi-: EN-GB"><FONT color=#808080>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BindableList&lt;Employee&gt; blist = </FONT></SPAN><SPAN lang=EN-GB style="COLOR: blue; mso-ansi-: EN-GB">new</SPAN><SPAN lang=EN-GB style="mso-ansi-: EN-GB"><FONT color=#808080> BindableList&lt;Employee&gt;();<o:p></o:p></FONT></SPAN></FONT></strong></FONT></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB style="mso-ansi-: EN-GB"><FONT size=2><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; blist.Add(emp);<o:p></o:p></FONT></strong></FONT></FONT></FONT></SPAN></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB style="mso-ansi-: EN-GB"><FONT size=2><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CreateEmployeeBitMap(emp);<o:p></o:p></FONT></strong></FONT></FONT></FONT></SPAN></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT size=2><FONT style=": #e6e6e6"><strong><FONT face="Courier New"><SPAN lang=EN-GB style="mso-ansi-: EN-GB"><FONT color=#808080>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN><SPAN style="COLOR: blue">return</SPAN><FONT color=#808080> blist;</FONT></FONT></strong></FONT></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><strong><FONT size=2><FONT color=#808080><FONT style=": #e6e6e6"><FONT face="Courier New">&nbsp;&nbsp;&nbsp; }<SPAN style="FONT-SIZE: 12pt"><o:p></o:p></SPAN></FONT></FONT></FONT></FONT></strong></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><FONT face="Times New Roman" size=2>Also, why do your prefer single-part keys?</P><DIV></DIV></FONT>]]>
   </description>
   <pubDate>Wed, 30 May 2007 16:52:14 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=23&amp;PID=74#74</guid>
  </item> 
 </channel>
</rss>