<?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 : NullReferenceException, DatasourceKeyName, EntityManager DataSourceResolver</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : NullReferenceException, DatasourceKeyName, EntityManager DataSourceResolver</description>
  <pubDate>Sat, 11 Apr 2026 04:31:42 -700</pubDate>
  <lastBuildDate>Wed, 21 Mar 2012 19:27:40 -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=3339</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>NullReferenceException, DatasourceKeyName, EntityManager DataSourceResolver : Thanks for the clarifications...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3339&amp;PID=13056#13056</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> 3339<br /><strong>Posted:</strong> 21-Mar-2012 at 7:27pm<br /><br />Thanks for the clarifications sebma. This defect has been fixed and will be included in 6.1.7 release.]]>
   </description>
   <pubDate>Wed, 21 Mar 2012 19:27:40 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3339&amp;PID=13056#13056</guid>
  </item> 
  <item>
   <title>NullReferenceException, DatasourceKeyName, EntityManager DataSourceResolver : Typo Correction: SomeNonExistentTypeInDomainModel...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3339&amp;PID=12996#12996</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=370" rel="nofollow">sebma</a><br /><strong>Subject:</strong> 3339<br /><strong>Posted:</strong> 15-Mar-2012 at 7:30pm<br /><br /><strong><U>Typo Correction:</U></strong><DIV></DIV>SomeNonExistentTypeInDomainModel - is just any class in your project,&nbsp;like&nbsp;String,&nbsp;which is <strong><U>NOT</U></strong> one of those concrete entity classes.]]>
   </description>
   <pubDate>Thu, 15 Mar 2012 19:30:55 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3339&amp;PID=12996#12996</guid>
  </item> 
  <item>
   <title>NullReferenceException, DatasourceKeyName, EntityManager DataSourceResolver : SomeNonExistentTypeInDomainModel...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3339&amp;PID=12995#12995</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=370" rel="nofollow">sebma</a><br /><strong>Subject:</strong> 3339<br /><strong>Posted:</strong> 15-Mar-2012 at 7:29pm<br /><br />SomeNonExistentTypeInDomainModel - is just any class in your project,&nbsp;like&nbsp;String,&nbsp;which is one of those concrete entity class.<DIV>&nbsp;</DIV><DIV>Fact is, it seems as long as no query or save operation is made via EntityManager, the DataSourceKeyName&nbsp;could be null, which is dangerous.</DIV><DIV>&nbsp;</DIV><DIV>Thanks for your clarifications.</DIV><DIV>-Seb</DIV>]]>
   </description>
   <pubDate>Thu, 15 Mar 2012 19:29:27 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3339&amp;PID=12995#12995</guid>
  </item> 
  <item>
   <title>NullReferenceException, DatasourceKeyName, EntityManager DataSourceResolver : Just to clarify the following...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3339&amp;PID=12994#12994</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> 3339<br /><strong>Posted:</strong> 15-Mar-2012 at 5:58pm<br /><br />Just to clarify the following code:<div><br></div><div><table width="99%"><tr><td><pre class="BBcode"></div><div><span style="text-align: left; : rgb251, 251, 253; ">StoredProcQuery query = new StoredProcQuery(typeof(int), "DummyNonExistentSP");</span><br style="text-align: left; : rgb251, 251, 253; "><span style="text-align: left; : rgb251, 251, 253; ">em.ExecuteQuery(query); // throws NullReferenceException</span></div><div><span style="text-align: left; : rgb251, 251, 253; "></pre></td></tr></table></span></div><div><span style="text-align: left; : rgb251, 251, 253; "><br></span></div><div><span style="text-align: left; : rgb251, 251, 253; ">The exception thrown here is not due to the StoredProc not existing. It's due to its DataSourceKeyName being null. Below are working and non working examples.</span></div><div><span style="text-align: left; : rgb251, 251, 253; "><br></span></div><div><span style="text-align: left; : rgb251, 251, 253; "><table width="99%"><tr><td><pre class="BBcode"></span></div><div><div><span style="text-align: left; : rgb251, 251, 253; ">StoredProcQuery query1 = new StoredProcQuery(typeof(int), "ExistingSpInYourModel");</span></div><div><span style=": rgb251, 251, 253; text-align: left; ">em.ExecuteQuery(query1);<span ="Apple-tab-span" style="white-space: pre; ">	</span>//Throws&nbsp;</span>NullRefException - DataSourceKeyName not set</div></div><div><br></div><div><span style="text-align: left; : rgb251, 251, 253; ">StoredProcQuery query2 = new StoredProcQuery(typeof(int), "DummyNonExistentSP");</span></div><div><span style="text-align: left; : rgb251, 251, 253; ">query2.DataSourceKeyName = "YourDsKeyHere";<span ="Apple-tab-span" style="white-space:pre">	</span>//DataSourceKeyName is set but........</span></div><div><span style="text-align: left; : rgb251, 251, 253; ">em.ExecuteQuery(query2);<span ="Apple-tab-span" style="white-space:pre">	</span>//Throws&nbsp;</span>System.InvalidOperationException: The FunctionImport could not be found</div><div><br></div><div style="text-align: left;"><span style=": rgb251, 251, 253; ">StoredProcQuery query3 = new StoredProcQuery(typeof(int), "ExistingSpInYourModel");</span></div><div><div><span style="text-align: left; : rgb251, 251, 253; ">query3.DataSourceKeyName = "YourDsKeyHere";</span></div><div><span style=": rgb251, 251, 253; text-align: left; ">em.ExecuteQuery(query3);<span ="Apple-tab-span" style="white-space: pre; ">	</span>//Now this works.</span></div></div><div><span style=": rgb251, 251, 253; text-align: left; "></pre></td></tr></table></span></div>]]>
   </description>
   <pubDate>Thu, 15 Mar 2012 17:58:47 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3339&amp;PID=12994#12994</guid>
  </item> 
  <item>
   <title>NullReferenceException, DatasourceKeyName, EntityManager DataSourceResolver : Hi sebma,Thank you for the feedback....</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3339&amp;PID=12993#12993</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> 3339<br /><strong>Posted:</strong> 15-Mar-2012 at 12:47pm<br /><br />Hi sebma,<div><br></div><div>Thank you for the feedback. It is expected but you're correct in that the exception message is not helpful. I'll file a bug report for this.</div><div><br></div><div>In the meantime, could you post the definition of your SomeNonExistentTypeInDomainModel?</div>]]>
   </description>
   <pubDate>Thu, 15 Mar 2012 12:47:23 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3339&amp;PID=12993#12993</guid>
  </item> 
  <item>
   <title>NullReferenceException, DatasourceKeyName, EntityManager DataSourceResolver :      Hi,  This got to do...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3339&amp;PID=12989#12989</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=370" rel="nofollow">sebma</a><br /><strong>Subject:</strong> 3339<br /><strong>Posted:</strong> 15-Mar-2012 at 1:01am<br /><br /><DIV></DIV><DIV></DIV><DIV></DIV><DIV></DIV><DIV></DIV><DIV>Hi,</DIV><DIV>&nbsp;</DIV><DIV>This got to do with EntityManager's DataSourceResolver.DataSourceKeyNames being empty on startup.</DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas></FONT></FONT>&nbsp;</DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>System.</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>NullReferenceException</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>: </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>Object</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> reference not set to an instance of an object. at IdeaBlade.EntityModel.DataSourceResolver.GetDataSourceKey(</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>Type</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> entityType) at IdeaBlade.EntityModel.EntityManager.CreateEntityGroupAndInitialize(</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>Type</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> entityType) at IdeaBlade.EntityModel.EntityManager.GetEntityGroup(</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>Type</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> entityType)</FONT></FONT></DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas></FONT></FONT>&nbsp;</DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>Just do the following:</FONT></FONT></DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas></FONT></FONT>&nbsp;</DIV><DIV>SomeDomainModelEntityManager em = new SomeDomainModelEntityManager();<BR>em.GetEntityGroup(typeof(SomeNonExistentTypeInDomainModel)); // throws NullReferenceException<BR>StoredProcQuery query = new StoredProcQuery(typeof(int), "DummyNonExistentSP");<BR>em.ExecuteQuery(query); // throws NullReferenceException</DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas></FONT></FONT>&nbsp;</DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas><DIV>Not sure if this is expected, even if it is, the exception type really not helpful.</DIV></DIV></FONT></FONT><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Thu, 15 Mar 2012 01:01:21 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3339&amp;PID=12989#12989</guid>
  </item> 
 </channel>
</rss>