<?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 : Unit Test And EntityManager.SaveChanges</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2009 : Unit Test And EntityManager.SaveChanges</description>
  <pubDate>Fri, 10 Apr 2026 21:37:20 -700</pubDate>
  <lastBuildDate>Fri, 09 Oct 2009 17:17:39 -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=1512</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>Unit Test And EntityManager.SaveChanges : You can make your PerformLogicAndSave()...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1512&amp;PID=5610#5610</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=4" rel="nofollow">GregD</a><br /><strong>Subject:</strong> 1512<br /><strong>Posted:</strong> 09-Oct-2009 at 5:17pm<br /><br />You can make your PerformLogicAndSave() method a little more discriminating, so that it only calls EntityManager.SaveChanges() when you want to hit the database; otherwise, you could have it do something else, like persist the changes to a local EntitySet file.<br><br>You could have it check to see if you're connected before deciding what to do, but that's quite time-consuming, so it's better to keep some flag that reflects your state of connectedness and/or whether you want to hit the database or not with saves and retrieves.<br>]]>
   </description>
   <pubDate>Fri, 09 Oct 2009 17:17:39 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1512&amp;PID=5610#5610</guid>
  </item> 
  <item>
   <title>Unit Test And EntityManager.SaveChanges : Am I missing the boat on what...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1512&amp;PID=5604#5604</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=598" rel="nofollow">rkierner</a><br /><strong>Subject:</strong> 1512<br /><strong>Posted:</strong> 09-Oct-2009 at 5:23am<br /><br />Am I missing the boat on what my method should do?&nbsp; While live, I do want to persist the changes to the DB.&nbsp; During testing, I obviously want to avoid hitting the DB.&nbsp; Is there any guidance on how to structure methods/object hierarchy so that my code is testable?<DIV>&nbsp;</DIV><DIV>Rick</DIV>]]>
   </description>
   <pubDate>Fri, 09 Oct 2009 05:23:02 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1512&amp;PID=5604#5604</guid>
  </item> 
  <item>
   <title>Unit Test And EntityManager.SaveChanges : SaveChanges() operates against...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1512&amp;PID=5603#5603</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=4" rel="nofollow">GregD</a><br /><strong>Subject:</strong> 1512<br /><strong>Posted:</strong> 08-Oct-2009 at 6:36pm<br /><br />SaveChanges() operates against the back-end datasource. Therefore you must be connected when performing a save.<br><br>You can instantiate an EntityManager, fill it with data from a local EntitySet file, make a bunch of changes, add new entities, save them to another local EntitySet file, etc., all while disconnected. But SaveChanges()? No.<br>]]>
   </description>
   <pubDate>Thu, 08 Oct 2009 18:36:43 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1512&amp;PID=5603#5603</guid>
  </item> 
  <item>
   <title>Unit Test And EntityManager.SaveChanges : I&amp;#039;m trying to write a test...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1512&amp;PID=5601#5601</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=598" rel="nofollow">rkierner</a><br /><strong>Subject:</strong> 1512<br /><strong>Posted:</strong> 08-Oct-2009 at 1:21pm<br /><br /><P>I'm trying to write a test and I'm running&nbsp;into an issue if I call SaveChanges on the EntityManager object.&nbsp; </P><DIV>I get the following Exception:</DIV><DIV>&nbsp;</DIV><DIV>"IdeaBlade.EntityModel.EntityManagerSaveException: This EntityManager is not currently connected - Reconnect before attempting to save."</DIV><DIV>&nbsp;</DIV><DIV>Am I missing something or is there a work around for this.&nbsp; My DomainModelEntityManager class extends from EntityManager and I pass in false to the constructor so that it can run disconnected.</DIV><DIV><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#091;TestMethod&#093;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void TestMyMethod()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var mgr = new DomainModelEntityManager(false);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var myObject = new MyClass { ID = 1};<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mgr.AttachEntity(myObject);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var myService = new MyService(mgr);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myService.PerformLogicAndSave(myObject);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV><P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public class MyService{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public MyService(EntityManager myManager){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MyManager = myManager;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public void PerformLogicAndSave(MyClass myObject){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//Do Something to myObject<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MyManager.SaveChanges();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</P>]]>
   </description>
   <pubDate>Thu, 08 Oct 2009 13:21:43 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1512&amp;PID=5601#5601</guid>
  </item> 
 </channel>
</rss>