<?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 : Minor bug with Entity Key</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Minor bug with Entity Key</description>
  <pubDate>Mon, 13 Apr 2026 01:17:16 -700</pubDate>
  <lastBuildDate>Fri, 09 Mar 2012 12:28:10 -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=3326</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>Minor bug with Entity Key : Hi stephenmcd1,Thank you for the...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3326&amp;PID=12949#12949</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 3326<br /><strong>Posted:</strong> 09-Mar-2012 at 12:28pm<br /><br /><div>Hi stephenmcd1,</div><div><br></div>Thank you for the feedback. I'll file a bug report for this.]]>
   </description>
   <pubDate>Fri, 09 Mar 2012 12:28:10 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3326&amp;PID=12949#12949</guid>
  </item> 
  <item>
   <title>Minor bug with Entity Key : If you pass in an array of value...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3326&amp;PID=12940#12940</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=613" rel="nofollow">stephenmcd1</a><br /><strong>Subject:</strong> 3326<br /><strong>Posted:</strong> 08-Mar-2012 at 3:21pm<br /><br />If you pass in an array of value types to the constructor of Entity Key, you get an exception. &nbsp;For example:<div><table width="99%"><tr><td><pre class="BBcode">var myKeyValues = new &#091;&#093; {123, 456}; //Compiler decides this should be an int&#091;&#093;</div><div>var key = new EntityKey(typeof(MyEntity), myKeyValues);</pre></td></tr></table></div><div>The EntityKey constructor will throw an exception like:</div><div><table width="99%"><tr><td><pre class="BBcode">System.InvalidCastException: Unable to cast object of type 'System.Int32&#091;&#093;' to type 'System.Object&#091;&#093;'.</div><div><div>&nbsp; &nbsp;at IdeaBlade.EntityModel.EntityKey..ctor(Type entityType, Object aValue, Boolean convertValue)</pre></td></tr></table></div></div><div>Looking at it in Reflector, it seems that constructor assumes that if the passed in value is an Array, it can safely cast it to an object array (object&#091;&#093;). &nbsp;But that is only true if the source array is of reference types (which is not the case in my example because I'm passing in an array of ints).</div><div><br></div><div>The workaround for this is pretty easy but I think it's still worth fixing (we just ran into this in a part of our code that doesn't get hit very often so we 'forgot' to use the workaround). &nbsp;For reference, the following code will work without a problem.</div><div><table width="99%"><tr><td><pre class="BBcode">var myKeyValues = new object&#091;&#093; {123, 456}; // Force boxing of the ints to workaround Dev Force issue</div><div>var key = new EntityKey(typeof(MyEntity), myKeyValues);</pre></td></tr></table></div>]]>
   </description>
   <pubDate>Thu, 08 Mar 2012 15:21:43 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3326&amp;PID=12940#12940</guid>
  </item> 
 </channel>
</rss>