<?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 : Saving just one object</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce Classic : Saving just one object</description>
  <pubDate>Wed, 13 May 2026 18:22:49 -700</pubDate>
  <lastBuildDate>Fri, 18 Apr 2008 06:26:19 -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=772</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>Saving just one object : SaveEntity(oEmpl)orSaveEntity(Of...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=772&amp;PID=2844#2844</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=152" rel="nofollow">f3rland</a><br /><strong>Subject:</strong> 772<br /><strong>Posted:</strong> 18-Apr-2008 at 6:26am<br /><br />&#091;VB&#093;<br>SaveEntity(oEmpl)<br>or<br>SaveEntity(Of Model.Employee)(oEmpl)<br><br>&#091;C#&#093;<br>SaveEntity(oEmpl);<br>or<br>SaveEntity&lt;Model.Employee&gt;(oEmpl);<br><br>]]>
   </description>
   <pubDate>Fri, 18 Apr 2008 06:26:19 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=772&amp;PID=2844#2844</guid>
  </item> 
  <item>
   <title>Saving just one object : Ok, I knew I was on the right...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=772&amp;PID=2843#2843</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=90" rel="nofollow">DataMan</a><br /><strong>Subject:</strong> 772<br /><strong>Posted:</strong> 17-Apr-2008 at 3:44pm<br /><br />Ok,&nbsp; I knew I was on the right track and after talking with Ideablade support we came up with the following code <DIV><FONT color=#2b91af size=2></FONT>&nbsp;</DIV><DIV><FONT color=#2b91af size=2>EntityList</FONT><FONT size=2>&lt;</FONT><FONT color=#2b91af size=2>Entity</FONT><FONT size=2>&gt; saveList = </FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> </FONT><FONT color=#2b91af size=2>EntityList</FONT><FONT size=2>&lt;</FONT><FONT color=#2b91af size=2>Entity</FONT><FONT size=2>&gt;();</DIV><DIV></FONT><FONT color=#2b91af size=2>EntityList</FONT><FONT size=2>&lt;</FONT><FONT color=#2b91af size=2>Employee</FONT><FONT size=2>&gt; mChangedEmployee = </FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> </FONT><FONT color=#2b91af size=2>EntityList</FONT><FONT size=2>&lt;</FONT><FONT color=#2b91af size=2>Employee</FONT><FONT size=2>&gt;();</DIV><DIV>mChangedEmployee.ReplaceRange(mPersMgr.GetEntities&lt;</FONT><FONT color=#2b91af size=2>Employee</FONT><FONT size=2>&gt;(</FONT><FONT color=#2b91af size=2>DataRowState</FONT><FONT size=2>.Modified));</DIV><DIV>mChangedEmployee.AddRange(mPersMgr.GetEntities&lt;</FONT><FONT color=#2b91af size=2>Employee</FONT><FONT size=2>&gt;(</FONT><FONT color=#2b91af size=2>DataRowState</FONT><FONT size=2>.Added));</FONT></DIV><DIV><FONT size=2>mChangedEmployee.AddRange(mPersMgr.GetEntities&lt;</FONT><FONT color=#2b91af size=2>Employee</FONT><FONT size=2>&gt;(</FONT><FONT color=#2b91af size=2>DataRowState</FONT><FONT size=2>.Deleted));</DIV><DIV></FONT><FONT color=#0000ff size=2></FONT>&nbsp;</DIV><DIV><FONT color=#0000ff size=2>foreach</FONT><FONT size=2> (</FONT><FONT color=#2b91af size=2>Entity</FONT><FONT size=2> mChanged </FONT><FONT color=#0000ff size=2>in</FONT><FONT size=2> mChangedEmployee)</FONT></DIV><DIV><FONT size=2>{</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; saveList.Add(mChanged);</DIV><DIV>}</DIV><DIV>mPersMgr.SaveChanges(saveList);</DIV><P>Now looking at&nbsp;f3rland's code above it shows passing the entire entity to the SaveEntity routine...&nbsp; Can you show me an example of calling the SaveEntity routine?&nbsp; Or is my above code the easiest way?</P><DIV></DIV><P>Thanks</FONT></P><span style="font-size:10px"><br /><br />Edited by DataMan - 17-Apr-2008 at 3:48pm</span>]]>
   </description>
   <pubDate>Thu, 17 Apr 2008 15:44:54 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=772&amp;PID=2843#2843</guid>
  </item> 
  <item>
   <title>Saving just one object : It&amp;#039;s weird that I was looking...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=772&amp;PID=2842#2842</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=90" rel="nofollow">DataMan</a><br /><strong>Subject:</strong> 772<br /><strong>Posted:</strong> 17-Apr-2008 at 1:30pm<br /><br />It's weird that I was looking to do the same thing and this was posted today!<DIV>&nbsp;</DIV><DIV>Excuse my ignorance in this post...</DIV><DIV>&nbsp;</DIV><DIV>So I modified my code to show the following</DIV><FONT size=2><P></FONT><FONT color=#2b91af size=2></P><DIV><FONT size=2><P></FONT><FONT color=#2b91af size=2></P><DIV>EntityList</FONT><FONT size=2>&lt;</FONT><FONT color=#2b91af size=2>ReportStorage</FONT><FONT size=2>&gt; mReportStorage = </FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> </FONT><FONT color=#2b91af size=2>EntityList</FONT><FONT size=2>&lt;</FONT><FONT color=#2b91af size=2>ReportStorage</FONT><FONT size=2>&gt;();</DIV><DIV></FONT>List</FONT><FONT size=2>&lt;</FONT><FONT color=#2b91af size=2>Entity</FONT><FONT size=2>&gt; oList = </FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> </FONT><FONT color=#2b91af size=2>List</FONT><FONT size=2>&lt;</FONT><FONT color=#2b91af size=2>Entity</FONT><FONT size=2>&gt;();</DIV></DIV><DIV>oList.Add(mReportStorage&#091;0&#093;);</DIV><DIV>mPersMgr.SaveChanges(oList);</DIV><P></FONT><FONT size=2>I only added the &#091;0&#093; because it worked and I knew that I had created an entity list called ReportStorage.&nbsp; Can someone give me an explaination on what the &#091;0&#093; is and is there anything stored in &#091;1&#093; or &#091;Xn&#093;?</P><DIV></DIV><DIV></DIV>Thanks<DIV></DIV></FONT>]]>
   </description>
   <pubDate>Thu, 17 Apr 2008 13:30:48 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=772&amp;PID=2842#2842</guid>
  </item> 
  <item>
   <title>Saving just one object :  Try thisPublic Sub SaveEntity(Of...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=772&amp;PID=2835#2835</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=152" rel="nofollow">f3rland</a><br /><strong>Subject:</strong> 772<br /><strong>Posted:</strong> 17-Apr-2008 at 8:20am<br /><br />Try this<br><br>&#091;VB&#093;<br>Public Sub SaveEntity(Of T As Entity)(ByVal pEntity As T)<br>&nbsp;&nbsp; Dim oList As New List(Of T)<br>&nbsp;&nbsp; oList.Add(pEntity)<br>&nbsp;&nbsp; PersistenceManager.DefaultManager.SaveChanges(oList)<br>End Sub<br><br>&#091;C#&#093;<span ="keyword"><br>public void SaveEntity&lt;T&gt;(T pEntity) where T : Entity<br>{<br>&nbsp;&nbsp;&nbsp; List&lt;T&gt; oList = new List&lt;T&gt;();<br>&nbsp;&nbsp;&nbsp; oList.Add(pEntity);<br>&nbsp;&nbsp;&nbsp; PersistenceManager.DefaultManager.SaveChanges(oList);<br>}</span><br><br>Handle with care when using it with child object... Make sure to save parent first.<br><img src="http://www.ideablade.com/forum/smileys/smiley23.gif" border="0" align="absmiddle" alt="Geek" /><br><span style="font-size:10px"><br /><br />Edited by f3rland - 17-Apr-2008 at 8:27am</span>]]>
   </description>
   <pubDate>Thu, 17 Apr 2008 08:20:59 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=772&amp;PID=2835#2835</guid>
  </item> 
  <item>
   <title>Saving just one object : I have a situation where I just...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=772&amp;PID=2834#2834</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=202" rel="nofollow">BillG</a><br /><strong>Subject:</strong> 772<br /><strong>Posted:</strong> 17-Apr-2008 at 8:09am<br /><br />I have a situation where I just want to save one object.&nbsp; Basically I am reading a value from a table, updating up and want to write the updated value back to the table.&nbsp;<DIV></DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>RdbQuery query = new RdbQuery(typeof(LocalInfo));</DIV><DIV>query.AddClause(LocalInfo.LocalIdEntityColumn, EntityQueryOp.EQ, 1);</DIV><DIV>LocalInfo = myPM.GetEntity&lt;LocalInfo&gt;(query);</DIV><DIV>Int32 nextId = local.NextEventNo;</DIV><DIV>local.NextEventNo = NextId + 1;</DIV><DIV>myPM.SaveChanges(????????);</DIV><DIV>return nextId;</DIV><DIV>&nbsp;</DIV><DIV>I only want to save the "local" object.&nbsp; LocalInfo is the information about the union local current logged into the app.</DIV><DIV>It doesn't like the myPM.SaveChanges(local).</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>Bill</DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Thu, 17 Apr 2008 08:09:21 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=772&amp;PID=2834#2834</guid>
  </item> 
 </channel>
</rss>