<?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 : Getting a DefaultManager (Sort of)</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2009 : Getting a DefaultManager (Sort of)</description>
  <pubDate>Mon, 13 Apr 2026 10:16:23 -700</pubDate>
  <lastBuildDate>Tue, 23 Jun 2009 10:39:13 -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=1342</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>Getting a DefaultManager (Sort of) : We were receiving the following...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1342&amp;PID=4833#4833</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=308" rel="nofollow">skingaby</a><br /><strong>Subject:</strong> 1342<br /><strong>Posted:</strong> 23-Jun-2009 at 10:39am<br /><br />We were receiving the following errors, depending on how we got into the code:<br />1) Error loading entity relations <br />2) Type conflict: the DefaultManager is currently of type EntityManager <br />3) Type Deal must inherit from Entity does not<br /><br />In our Deal class, I had implemented a static Create method:<br /><br />public static Deal Create(User user)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;Deal deal = _manager.CreateEntity&lt;Deal&gt;();<br />&nbsp;&nbsp;&nbsp;&nbsp;GetATemporaryKey(deal);<br />&nbsp;&nbsp;&nbsp;&nbsp;InitializeDefaults(deal, user);<br />&nbsp;&nbsp;&nbsp;&nbsp;AddToManager(deal);<br />&nbsp;&nbsp;&nbsp;&nbsp;InitializeChildren(deal, user);<br />&nbsp;&nbsp;&nbsp;&nbsp;return deal;<br />}<br /><br />which used a static private EntityManager which was declared like this:<br /><br />static DomainModelEntityManager _manager = DomainModelEntityManager.DefaultManager;<br /><br />It turns out that at run time, this is actually initialized to an EntityManager, NOT a DomainModelEntityManager as I had expected.<br /><br />I created a new LocalEntityManager class like this:<br /><br />public static class LocalEntityManager<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;private static DomainModelEntityManager _em; <br /><br />&nbsp;&nbsp;&nbsp;&nbsp;public static DomainModelEntityManager DefaultManager<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (_em == null)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  _em = new DomainModelEntityManager();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return _em;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /> <br />and changed the declaration in Deal like this:<br /><br />static DomainModelEntityManager _manager = LocalEntityManager.DefaultManager;<br /><br />Now, it all works like a charm.  <br />&#091;It only took 2 days to find this...&#093;]]>
   </description>
   <pubDate>Tue, 23 Jun 2009 10:39:13 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1342&amp;PID=4833#4833</guid>
  </item> 
 </channel>
</rss>