<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How to implement a many-to-many relationship using Linq to Sql ? Part II : add/remove support</title><link>http://blogs.msdn.com/b/mitsu/archive/2008/03/19/how-to-implement-a-many-to-many-relationship-using-linq-to-sql-part-ii-add-remove-support.aspx</link><description>In my previous post ( http://blogs.msdn.com/mitsu/archive/2007/06/21/how-to-implement-a-many-to-many-relationship-using-linq-to-sql.aspx ), I had proposed a simple solution for implementing many-to-many relationships using Linq to Sql. Actually, this</description><dc:language>en</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: How to implement a many-to-many relationship using Linq to Sql ? Part II : add/remove support</title><link>http://blogs.msdn.com/b/mitsu/archive/2008/03/19/how-to-implement-a-many-to-many-relationship-using-linq-to-sql-part-ii-add-remove-support.aspx#9044928</link><pubDate>Wed, 05 Nov 2008 21:40:26 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9044928</guid><dc:creator>Carl</dc:creator><description>&lt;p&gt;I get a System.InvalidOperationException when I try to remove a newly added product:&lt;/p&gt;
&lt;p&gt;Cannot remove an entity that has not been attached.&lt;/p&gt;
&lt;p&gt;On line 22 of Nortwind.custom.cs.&lt;/p&gt;
&lt;p&gt;Can this easily be fixed?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9044928" width="1" height="1"&gt;</description></item><item><title>re: How to implement a many-to-many relationship using Linq to Sql ? Part II : add/remove support</title><link>http://blogs.msdn.com/b/mitsu/archive/2008/03/19/how-to-implement-a-many-to-many-relationship-using-linq-to-sql-part-ii-add-remove-support.aspx#8963423</link><pubDate>Wed, 24 Sep 2008 12:40:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8963423</guid><dc:creator>MadSpartan</dc:creator><description>&lt;p&gt;Thanks a lot for the code... It really solved my hands...&lt;/p&gt;
&lt;p&gt;One question though (just out of curiousity)... I was testing it and when creating the add delegate intead of writing:&lt;/p&gt;
&lt;p&gt;(ods, p) =&amp;gt; ods.Add( new Order_Detail { &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;OrderID = this.OrderID, Product = p,&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;Quantity=1 }, ....&lt;/p&gt;
&lt;p&gt;I wrote:&lt;/p&gt;
&lt;p&gt;(ods, p) =&amp;gt; ods.Add( new Order_Detail { &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;Order = this, Product = p,&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;Quantity=1 }, ....&lt;/p&gt;
&lt;p&gt;which seems a lot more OO to me (and nevertheless makes equal sense since actually setting the Order sets the OrderID too). This makes the .NET runtime throw an ArgumentOutOfRange exception when adding the new Order_Details which almost drove me nuts before spotting the difference...&lt;/p&gt;
&lt;p&gt;Anyway, does anybody know why is this happening? And why it is not happenning with the Product property?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8963423" width="1" height="1"&gt;</description></item><item><title>re: How to implement a many-to-many relationship using Linq to Sql ? Part II : add/remove support</title><link>http://blogs.msdn.com/b/mitsu/archive/2008/03/19/how-to-implement-a-many-to-many-relationship-using-linq-to-sql-part-ii-add-remove-support.aspx#8609451</link><pubDate>Tue, 17 Jun 2008 08:50:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8609451</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt; &amp;nbsp;This works great. How would I use it in a dynamic data appliaction?&lt;/p&gt;
&lt;p&gt; &amp;nbsp; Dave Ebbo linked to this as a solution, but I am unsure how that would work. &lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://blogs.msdn.com/davidebb/archive/2007/12/12/dynamic-data-screencast-is-now-available.aspx"&gt;http://blogs.msdn.com/davidebb/archive/2007/12/12/dynamic-data-screencast-is-now-available.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;Thanks&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;Chris&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8609451" width="1" height="1"&gt;</description></item><item><title>Mitsu's blog : How to implement a many-to-many relationship using Linq to Sql ? Part II : add/remove support</title><link>http://blogs.msdn.com/b/mitsu/archive/2008/03/19/how-to-implement-a-many-to-many-relationship-using-linq-to-sql-part-ii-add-remove-support.aspx#8574875</link><pubDate>Thu, 05 Jun 2008 12:50:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8574875</guid><dc:creator>Weddings</dc:creator><description>&lt;p&gt;In my previous post ( &lt;a rel="nofollow" target="_new" href="http://blogs.msdn.com/mitsu/archive/2007/06/21/how-to-implement-a-many-to-many-relationship-using-linq-to-sql.aspx"&gt;http://blogs.msdn.com/mitsu/archive/2007/06/21/how-to-implement-a-many-to-many-relationship-using-linq-to-sql.aspx&lt;/a&gt; ), I had proposed a simple solution for implementing many-to-many relationships using Linq to Sql. Actually, this&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8574875" width="1" height="1"&gt;</description></item><item><title>Mitsu's blog : How to implement a many-to-many relationship using Linq to Sql ? Part II : add/remove support</title><link>http://blogs.msdn.com/b/mitsu/archive/2008/03/19/how-to-implement-a-many-to-many-relationship-using-linq-to-sql-part-ii-add-remove-support.aspx#8553291</link><pubDate>Mon, 26 May 2008 22:47:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8553291</guid><dc:creator>Dating</dc:creator><description>&lt;p&gt;In my previous post ( &lt;a rel="nofollow" target="_new" href="http://blogs.msdn.com/mitsu/archive/2007/06/21/how-to-implement-a-many-to-many-relationship-using-linq-to-sql.aspx"&gt;http://blogs.msdn.com/mitsu/archive/2007/06/21/how-to-implement-a-many-to-many-relationship-using-linq-to-sql.aspx&lt;/a&gt; ), I had proposed a simple solution for implementing many-to-many relationships using Linq to Sql. Actually, this&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8553291" width="1" height="1"&gt;</description></item><item><title>re: How to implement a many-to-many relationship using Linq to Sql ? Part II : add/remove support</title><link>http://blogs.msdn.com/b/mitsu/archive/2008/03/19/how-to-implement-a-many-to-many-relationship-using-linq-to-sql-part-ii-add-remove-support.aspx#8519831</link><pubDate>Tue, 20 May 2008 01:23:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8519831</guid><dc:creator>Ecard guy</dc:creator><description>&lt;p&gt;Thank you for providing all of this helpful information.&lt;/p&gt;
&lt;p&gt;It would be very helpful to understand what's different about Linq to Entities that allows it to support many2many whilst Linq to SQL does not.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8519831" width="1" height="1"&gt;</description></item><item><title>How to implement a many-to-many relationship using Linq to Sql ? (转)</title><link>http://blogs.msdn.com/b/mitsu/archive/2008/03/19/how-to-implement-a-many-to-many-relationship-using-linq-to-sql-part-ii-add-remove-support.aspx#8487758</link><pubDate>Sun, 11 May 2008 19:14:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8487758</guid><dc:creator>江南白衣</dc:creator><description>&lt;p&gt;In this article, I will show one possible solution to implement many-to-many relationship using Linq to Sql.&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8487758" width="1" height="1"&gt;</description></item><item><title>re: How to implement a many-to-many relationship using Linq to Sql ? Part II : add/remove support</title><link>http://blogs.msdn.com/b/mitsu/archive/2008/03/19/how-to-implement-a-many-to-many-relationship-using-linq-to-sql-part-ii-add-remove-support.aspx#8475401</link><pubDate>Fri, 09 May 2008 02:11:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8475401</guid><dc:creator>Mitsu Furuta</dc:creator><description>&lt;p&gt;Hi Nelis,&lt;/p&gt;
&lt;p&gt;I don't see what you mean. Please could you detail more ?&lt;/p&gt;
&lt;p&gt;This solution is only a client side syntax simplification to allow direct access between to entities of a many to many relationship. (just in memory solution).&lt;/p&gt;
&lt;p&gt;It does not change the way data are physically loaded. If in your case you choose to use linq to sql deferred loading, it's your choice.&lt;/p&gt;
&lt;p&gt;If you prefer preloading details entities, you can use DataContext load options.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8475401" width="1" height="1"&gt;</description></item><item><title>re: How to implement a many-to-many relationship using Linq to Sql ? Part II : add/remove support</title><link>http://blogs.msdn.com/b/mitsu/archive/2008/03/19/how-to-implement-a-many-to-many-relationship-using-linq-to-sql-part-ii-add-remove-support.aspx#8471343</link><pubDate>Thu, 08 May 2008 15:01:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8471343</guid><dc:creator>Nelis</dc:creator><description>&lt;p&gt;How come, nobody complains about detail objects being fetched on a one-by-one basis? Lots of database roundtrips...&lt;/p&gt;
&lt;p&gt;Am I missing something?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8471343" width="1" height="1"&gt;</description></item><item><title>Implement a many-to-many relationship in LINQ to SQL</title><link>http://blogs.msdn.com/b/mitsu/archive/2008/03/19/how-to-implement-a-many-to-many-relationship-using-linq-to-sql-part-ii-add-remove-support.aspx#8428256</link><pubDate>Sat, 26 Apr 2008 21:06:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8428256</guid><dc:creator>Hot Topics</dc:creator><description>&lt;p&gt;Mitsu Furata explores many-to-many relationships in LINQ to SQL in these two posts: How to implement&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8428256" width="1" height="1"&gt;</description></item></channel></rss>