<?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 : Many-to-many: Just save the linking object??</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Many-to-many: Just save the linking object??</description>
  <pubDate>Mon, 13 Apr 2026 17:19:21 -700</pubDate>
  <lastBuildDate>Mon, 16 May 2011 00:28:36 -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=2667</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>Many-to-many: Just save the linking object?? : Thanks, that helps me a lot!1)...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2667&amp;PID=10694#10694</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1095" rel="nofollow">AuerRo</a><br /><strong>Subject:</strong> 2667<br /><strong>Posted:</strong> 16-May-2011 at 12:28am<br /><br />Thanks, that helps me a lot!<div><br></div><div>1) I absolutely agree, but unfortunately I'm facing clients that would rather undo an edit manually than using a restore-button.</div><div><br></div><div>2) That's my way!</div><div><br></div><div>Thanks for your help!</div><div>Roland</div><div><br></div><div>PS: Wouldn't it be a nice feature for a future release to be able to determine if a m2m-relationship changed? It's a bit confusing if I have an EntityManager with changes, but every Entity's EntityState is unchanged.</div>]]>
   </description>
   <pubDate>Mon, 16 May 2011 00:28:36 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2667&amp;PID=10694#10694</guid>
  </item> 
  <item>
   <title>Many-to-many: Just save the linking object?? : Hi Roland,   Thanks for clarifying.   Unfortunately,...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2667&amp;PID=10659#10659</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=892" rel="nofollow">sbelini</a><br /><strong>Subject:</strong> 2667<br /><strong>Posted:</strong> 12-May-2011 at 9:47am<br /><br /><P>Hi Roland, </P><DIV></DIV><DIV>Thanks for clarifying.</DIV><DIV>&nbsp;</DIV><DIV></DIV><DIV>Unfortunately, in a m2m with no payload, you will not be able to accomplish this. </DIV><DIV>&nbsp;</DIV><DIV>In this situation, even with a partial save (i.e. SaveChanges(new Entity&#091;&#093; {anEmployee}); or SaveChanges(new Entity&#091;&#093; {aTask}); ) will save the whole Employee-LinkingTable-Task trio.</DIV><DIV></DIV><DIV>&nbsp;</DIV><DIV>1) technically, if you manually changed the value back to its original, it would actually be a second change rather than a restore. In this case you will need to compare values to determine if it was a restore or another change. Then again, it won't apply on Navigation properties.</DIV><DIV>You might also consider using RejectChanges:</DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>myEmployee.EntityAspect.RejectChanges();</FONT></FONT></DIV><DIV></DIV><DIV>&nbsp;</DIV><DIV>2) a m2m with payload will give you the freedom to manipulate the linking table directly. </DIV><DIV></DIV><DIV>&nbsp;</DIV><DIV>Silvio.</DIV>]]>
   </description>
   <pubDate>Thu, 12 May 2011 09:47:49 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2667&amp;PID=10659#10659</guid>
  </item> 
  <item>
   <title>Many-to-many: Just save the linking object?? : Hi Silvio! Thanks for the answer.Let...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2667&amp;PID=10654#10654</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1095" rel="nofollow">AuerRo</a><br /><strong>Subject:</strong> 2667<br /><strong>Posted:</strong> 12-May-2011 at 9:11am<br /><br /><div style=": rgb255, 255, 255; margin-left: 1px; margin-top: 1px; margin-right: 1px; margin-bottom: 1px; font-family: Verdana, Arial, Helvetica, sans-serif; color: rgb0, 0, 0; font-size: 12px; line-height: 1.4; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; -: n&#111;ne; ">Hi Silvio! Thanks for the answer.<div style="font-weight: normal; "><br></div><div style="font-weight: normal; ">Let me clarify the problem by using an example.</div><div style="font-weight: normal; "><br></div><div style="font-weight: normal; ">I have two entities, Employee and Task, connected m2m without payload;&nbsp;(One Employee can work on many Tasks, on Task can be assigned to many Employees);</div><div style="font-weight: normal; "><br></div><div>If I add or remove a User from Task.Users, how am I able to save that, without saving the Task-Entity itself? Something like <b>SaveChanges(Task.Users)</b>; but it seems that this is not possible, or am I wrong?</div><div style="font-weight: normal; "><br></div><div style="font-weight: normal; ">Questions to your answers of my questions:</div><div><span ="Apple-style-span" style="font-weight: normal; ">1) That's clear. But how do I check if a m2m navigation property changed at all? For example, if i manually restore the collection in the ui to the value it was before the first change, I want the IsDirty-flag to be false. For every dataproperty in an entity, i can take all </span><b>DataProperties (from EntityAspect.EntityMetadata.DataProperties)</b> and compare <b>property.GetValue(entity, EntityVersion.Original)</b> to <b>property.GetValue(entity, EntityVersion.Proposed)</b>;</div><div style="font-weight: normal; "><br></div><div><span ="Apple-style-span" style="font-weight: normal; ">The problem is, I can't get any EntityVersion with the </span><b>ListNavigationProperties (EntityAspect.EntityMetadata.ListNavigationProperties)</b>, so I can't check if they changed or a change was undone by the user.</div><div style="font-weight: normal; "><br></div><div style="font-weight: normal; ">2) No question on that. Maybe that would be a solution, just to fake a payload so that I can save the change immediately.</div><div style="font-weight: normal; "><br></div><div style="font-weight: normal; ">Thanks for your help!</div><div style="font-weight: normal; ">Roland</div></div>]]>
   </description>
   <pubDate>Thu, 12 May 2011 09:11:50 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2667&amp;PID=10654#10654</guid>
  </item> 
  <item>
   <title>Many-to-many: Just save the linking object?? :  Hi Roland,    Not sure what...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2667&amp;PID=10648#10648</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=892" rel="nofollow">sbelini</a><br /><strong>Subject:</strong> 2667<br /><strong>Posted:</strong> 11-May-2011 at 3:42pm<br /><br /><P><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-: EN" lang=EN></P><DIV>Hi Roland,</DIV><DIV>&nbsp;</DIV><DIV><?: prefix = o ns = "urn:schemas-microsoft-com:office:office" /><O:P></O:P></SPAN></DIV><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-: EN" lang=EN><DIV></DIV><DIV></SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-: EN" lang=EN>Not sure what you mean by </SPAN><I><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt; mso-ansi-: EN" lang=EN>calling SaveChanges() on the linked entity</SPAN></I><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-: EN" lang=EN>... do you mean calling a partial save?</SPAN></DIV><DIV><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-: EN" lang=EN><O:P></O:P></SPAN></DIV><B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt; mso-ansi-: EN" lang=EN><DIV></DIV><DIV>SaveChanges(new Entity&#091;&#093; {entityToBeSaved});</SPAN></B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-: EN" lang=EN><O:P></O:P></SPAN></DIV><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-: EN" lang=EN><DIV></DIV><DIV>&nbsp;</DIV><DIV>It that's what you mean, then the linking entity (of a m2m with no payload relation) will also be saved.</DIV><DIV><DIV><P style="MARGIN: 0.75pt 1.5pt" ="Ms&#111;normal"><O:P></O:P></SPAN></P><DIV><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-: EN" lang=EN></SPAN></DIV><DIV><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-: EN" lang=EN></SPAN>&nbsp;</DIV><DIV><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-: EN" lang=EN>Please clarify so I can better understand what you are describing.</SPAN></DIV></DIV></DIV><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-: EN" lang=EN><DIV></DIV><DIV>&nbsp;</DIV><DIV>Answering your questions:<O:P></O:P></SPAN></DIV><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-: EN" lang=EN><DIV>1) You can add an EventHandler to the CollectionChanged event of the entity's nav property:</DIV><DIV>&nbsp;</DIV><DIV><O:P></O:P></SPAN></DIV><P style="MARGIN: 0.75pt 1.5pt" ="Ms&#111;normal"><SPAN style="FONT-FAMILY: C&#111;nsolas; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-: EN" lang=EN>employee.Territories.CollectionChanged += </SPAN><SPAN style="FONT-FAMILY: C&#111;nsolas; COLOR: blue; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-: EN" lang=EN>new</SPAN><SPAN style="FONT-FAMILY: C&#111;nsolas; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-: EN" lang=EN> System.Collections.Specialized.</SPAN><SPAN style="FONT-FAMILY: C&#111;nsolas; COLOR: #2b91af; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-: EN" lang=EN>NotifyCollectionChangedEventHandler</SPAN><SPAN style="FONT-FAMILY: C&#111;nsolas; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-: EN" lang=EN>(Territories_CollectionChanged);</P><DIV><DIV><P style="MARGIN: 0.75pt 1.5pt" ="Ms&#111;normal"></SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-: EN" lang=EN><O:P></O:P></SPAN></P><DIV><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-: EN" lang=EN></SPAN></DIV><DIV><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-: EN" lang=EN></SPAN>&nbsp;</DIV><DIV><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-: EN" lang=EN>2) You won't be able to do that in a m2m with no payload linking table. You could do it if you had a m2m with payload... However, you must be aware that you can only call a partial save on the linking table if both entities already exist in the datasource. Otherwise, you must commit the Added entity(ies) as well. (otherwise you will have an exception due to not resolving all temporary IDs)</SPAN></DIV></DIV></DIV><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-: EN" lang=EN><DIV></DIV><DIV>&nbsp;</DIV><DIV>Silvio.<O:P></O:P></SPAN></DIV><span style="font-size:10px"><br /><br />Edited by sbelini - 11-May-2011 at 3:43pm</span>]]>
   </description>
   <pubDate>Wed, 11 May 2011 15:42:54 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2667&amp;PID=10648#10648</guid>
  </item> 
  <item>
   <title>Many-to-many: Just save the linking object?? : Hi,I have a many-to-many relationship...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2667&amp;PID=10637#10637</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1095" rel="nofollow">AuerRo</a><br /><strong>Subject:</strong> 2667<br /><strong>Posted:</strong> 11-May-2011 at 8:27am<br /><br />Hi,<div><br></div><div>I have a many-to-many relationship with no payload.&nbsp;</div><div>According to <a href="http://drc.ideablade.com/xwiki/bin/view/&#068;ocumentati&#111;n/adding-removing-related-&#111;bjects#HAdd2829andRemove2829&#111;nmany-to-manynavigati&#111;nproperties" target="_blank">this</a> article in the docs, calling SaveChanges() on the linked entity saves the linking object.</div><div><br></div><div>In my application I can only save an entity when it is dirty, so the linking object won't be saved, as the entity stays unchanged when a many-to-many-relation is added. Whereas if i call SaveChanges() on the linked entity, every change beside the linking object will also be saved, and that's something i do not want.</div><div><br></div><div>In order to solve this, I have two questions:</div><div><ol><li>Is there a way to determine if a m2m-relation is added to an entity? That could change the "is dirty state".</li><li>Or: Is there a way to only save the linking object, without saving the entity's changes?</li></ol><div>Thanks for any help in advance!</div></div><div>Roland</div>]]>
   </description>
   <pubDate>Wed, 11 May 2011 08:27:08 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2667&amp;PID=10637#10637</guid>
  </item> 
 </channel>
</rss>