<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Wizz's Coding Solutions &#187; Linq to SQL</title>
	<atom:link href="http://rainstorms.me.uk/blog/tag/linq-to-sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://rainstorms.me.uk/blog</link>
	<description>Problems that I come across in day to day coding</description>
	<lastBuildDate>Thu, 07 Jul 2011 07:50:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Linq to SQL Query gives an InvalidOperationException with message &#8220;Cannot compare entities associated with different tables.&#8221;</title>
		<link>http://rainstorms.me.uk/blog/2010/09/15/linq-to-sql-query-gives-an-invalidoperationexception-with-message-cannot-compare-entities-associated-with-different-tables/</link>
		<comments>http://rainstorms.me.uk/blog/2010/09/15/linq-to-sql-query-gives-an-invalidoperationexception-with-message-cannot-compare-entities-associated-with-different-tables/#comments</comments>
		<pubDate>Wed, 15 Sep 2010 20:19:56 +0000</pubDate>
		<dc:creator>wizzard</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Cannot compare entities associated with different tables.]]></category>
		<category><![CDATA[InvalidOperationException]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[Linq to SQL]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://rainstorms.me.uk/blog/?p=346</guid>
		<description><![CDATA[If you try to do a Linq to SQL query and it runs fine, but gives you an exception of type InvalidOperationException and the message is &#8220;Cannot compare entities associated with different tables.&#8221; then it probably means that you are trying to pass in an object of one type and compare it to another type. [...]


No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>If you try to do a Linq to SQL query and it runs fine, but gives you an exception of type InvalidOperationException and the message is &#8220;Cannot compare entities associated with different tables.&#8221; then it probably means that you are trying to pass in an object of one type and compare it to another type.  I suspect that you will probably only get this error if Linq attempts to translate the error to SQL &#8211; if you run it in memory, you might not get an error at all, as it may just do a straight object comparison and conclude that they are different objects.</p>
<p>An example would be something like</p>
<pre name="code" class="vb.net">

Dim p = DBContext.People.First
Dim q = From a in DBContext.Addresses Where a Is p
Dim addr = q.First
</pre>
<p>The final line will result in this exception as Linq to SQL is attempting to translate the query into SQL and it (correctly) can&#8217;t find any way of writing a query that compares a person to an address!</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark this post</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F09%2F15%2Flinq-to-sql-query-gives-an-invalidoperationexception-with-message-cannot-compare-entities-associated-with-different-tables%2F&amp;title=Linq+to+SQL+Query+gives+an+InvalidOperationException+with+message+%26%238220%3BCannot+compare+entities+associated+with+different+tables.%26%238221%3B" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F09%2F15%2Flinq-to-sql-query-gives-an-invalidoperationexception-with-message-cannot-compare-entities-associated-with-different-tables%2F&amp;title=Linq+to+SQL+Query+gives+an+InvalidOperationException+with+message+%26%238220%3BCannot+compare+entities+associated+with+different+tables.%26%238221%3B" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F09%2F15%2Flinq-to-sql-query-gives-an-invalidoperationexception-with-message-cannot-compare-entities-associated-with-different-tables%2F&amp;title=Linq+to+SQL+Query+gives+an+InvalidOperationException+with+message+%26%238220%3BCannot+compare+entities+associated+with+different+tables.%26%238221%3B" rel="nofollow" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F09%2F15%2Flinq-to-sql-query-gives-an-invalidoperationexception-with-message-cannot-compare-entities-associated-with-different-tables%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://FriendSite.com/users/bookmarks/?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F09%2F15%2Flinq-to-sql-query-gives-an-invalidoperationexception-with-message-cannot-compare-entities-associated-with-different-tables%2F&amp;t=Linq+to+SQL+Query+gives+an+InvalidOperationException+with+message+%26%238220%3BCannot+compare+entities+associated+with+different+tables.%26%238221%3B" rel="nofollow" title="Add to&nbsp;FriendSite"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/friendsite.png" title="Add to&nbsp;FriendSite" alt="Add to&nbsp;FriendSite" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F09%2F15%2Flinq-to-sql-query-gives-an-invalidoperationexception-with-message-cannot-compare-entities-associated-with-different-tables%2F&amp;title=Linq+to+SQL+Query+gives+an+InvalidOperationException+with+message+%26%238220%3BCannot+compare+entities+associated+with+different+tables.%26%238221%3B" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F09%2F15%2Flinq-to-sql-query-gives-an-invalidoperationexception-with-message-cannot-compare-entities-associated-with-different-tables%2F&amp;title=Linq+to+SQL+Query+gives+an+InvalidOperationException+with+message+%26%238220%3BCannot+compare+entities+associated+with+different+tables.%26%238221%3B" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F09%2F15%2Flinq-to-sql-query-gives-an-invalidoperationexception-with-message-cannot-compare-entities-associated-with-different-tables%2F&amp;title=Linq+to+SQL+Query+gives+an+InvalidOperationException+with+message+%26%238220%3BCannot+compare+entities+associated+with+different+tables.%26%238221%3B" rel="nofollow" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F09%2F15%2Flinq-to-sql-query-gives-an-invalidoperationexception-with-message-cannot-compare-entities-associated-with-different-tables%2F&amp;title=Linq+to+SQL+Query+gives+an+InvalidOperationException+with+message+%26%238220%3BCannot+compare+entities+associated+with+different+tables.%26%238221%3B" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.shoutwire.com/?p=submit&amp;link=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F09%2F15%2Flinq-to-sql-query-gives-an-invalidoperationexception-with-message-cannot-compare-entities-associated-with-different-tables%2F" rel="nofollow" title="Add to&nbsp;Shoutwire"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/shoutwire.png" title="Add to&nbsp;Shoutwire" alt="Add to&nbsp;Shoutwire" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F09%2F15%2Flinq-to-sql-query-gives-an-invalidoperationexception-with-message-cannot-compare-entities-associated-with-different-tables%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F09%2F15%2Flinq-to-sql-query-gives-an-invalidoperationexception-with-message-cannot-compare-entities-associated-with-different-tables%2F&amp;t=Linq+to+SQL+Query+gives+an+InvalidOperationException+with+message+%26%238220%3BCannot+compare+entities+associated+with+different+tables.%26%238221%3B" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://rainstorms.me.uk/blog/2010/09/15/linq-to-sql-query-gives-an-invalidoperationexception-with-message-cannot-compare-entities-associated-with-different-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Finding a table in a Linq to SQL DBML file in Visual Studio 2008</title>
		<link>http://rainstorms.me.uk/blog/2010/03/01/finding-a-table-in-a-linq-to-sql-dbml-file-in-visual-studio-2008/</link>
		<comments>http://rainstorms.me.uk/blog/2010/03/01/finding-a-table-in-a-linq-to-sql-dbml-file-in-visual-studio-2008/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 14:26:20 +0000</pubDate>
		<dc:creator>wizzard</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Control+F]]></category>
		<category><![CDATA[DBML]]></category>
		<category><![CDATA[Find table]]></category>
		<category><![CDATA[Linq to SQL]]></category>
		<category><![CDATA[Properties window]]></category>
		<category><![CDATA[Visual Studio 2008]]></category>

		<guid isPermaLink="false">http://rainstorms.me.uk/blog/?p=287</guid>
		<description><![CDATA[One problem that can take up a lot of time if you are working in a large project with a lot of tables in the DBML database model file when using Linq to SQL in Visual Studio is finding the table in the diagram.  Control+F doesn&#8217;t work, and it can be a real pain to [...]


No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>One problem that can take up a lot of time if you are working in a large project with a lot of tables in the DBML database model file when using Linq to SQL in Visual Studio is finding the table in the diagram.  Control+F doesn&#8217;t work, and it can be a real pain to scroll around for ages.  However, the following article mentions a very simple solution &#8211; just use the dropdown at the top of the properties window!  Seems obvious, but I know quite a few people have been complaining about that for months!</p>
<p>Taken from <a href="http://stackoverflow.com/questions/916460/Is-there-a-way-to-find-a-table-in-a-DBML-file-in-Visual-Studio-2008-">Is there a way to find a table in a DBML file in Visual Studio 2008? &#8211; Stack Overflow</a>.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark this post</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F03%2F01%2Ffinding-a-table-in-a-linq-to-sql-dbml-file-in-visual-studio-2008%2F&amp;title=Finding+a+table+in+a+Linq+to+SQL+DBML+file+in+Visual+Studio+2008" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F03%2F01%2Ffinding-a-table-in-a-linq-to-sql-dbml-file-in-visual-studio-2008%2F&amp;title=Finding+a+table+in+a+Linq+to+SQL+DBML+file+in+Visual+Studio+2008" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F03%2F01%2Ffinding-a-table-in-a-linq-to-sql-dbml-file-in-visual-studio-2008%2F&amp;title=Finding+a+table+in+a+Linq+to+SQL+DBML+file+in+Visual+Studio+2008" rel="nofollow" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F03%2F01%2Ffinding-a-table-in-a-linq-to-sql-dbml-file-in-visual-studio-2008%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://FriendSite.com/users/bookmarks/?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F03%2F01%2Ffinding-a-table-in-a-linq-to-sql-dbml-file-in-visual-studio-2008%2F&amp;t=Finding+a+table+in+a+Linq+to+SQL+DBML+file+in+Visual+Studio+2008" rel="nofollow" title="Add to&nbsp;FriendSite"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/friendsite.png" title="Add to&nbsp;FriendSite" alt="Add to&nbsp;FriendSite" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F03%2F01%2Ffinding-a-table-in-a-linq-to-sql-dbml-file-in-visual-studio-2008%2F&amp;title=Finding+a+table+in+a+Linq+to+SQL+DBML+file+in+Visual+Studio+2008" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F03%2F01%2Ffinding-a-table-in-a-linq-to-sql-dbml-file-in-visual-studio-2008%2F&amp;title=Finding+a+table+in+a+Linq+to+SQL+DBML+file+in+Visual+Studio+2008" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F03%2F01%2Ffinding-a-table-in-a-linq-to-sql-dbml-file-in-visual-studio-2008%2F&amp;title=Finding+a+table+in+a+Linq+to+SQL+DBML+file+in+Visual+Studio+2008" rel="nofollow" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F03%2F01%2Ffinding-a-table-in-a-linq-to-sql-dbml-file-in-visual-studio-2008%2F&amp;title=Finding+a+table+in+a+Linq+to+SQL+DBML+file+in+Visual+Studio+2008" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.shoutwire.com/?p=submit&amp;link=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F03%2F01%2Ffinding-a-table-in-a-linq-to-sql-dbml-file-in-visual-studio-2008%2F" rel="nofollow" title="Add to&nbsp;Shoutwire"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/shoutwire.png" title="Add to&nbsp;Shoutwire" alt="Add to&nbsp;Shoutwire" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F03%2F01%2Ffinding-a-table-in-a-linq-to-sql-dbml-file-in-visual-studio-2008%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F03%2F01%2Ffinding-a-table-in-a-linq-to-sql-dbml-file-in-visual-studio-2008%2F&amp;t=Finding+a+table+in+a+Linq+to+SQL+DBML+file+in+Visual+Studio+2008" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://rainstorms.me.uk/blog/2010/03/01/finding-a-table-in-a-linq-to-sql-dbml-file-in-visual-studio-2008/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Linq to SQL Quirks Part 4: Circular References</title>
		<link>http://rainstorms.me.uk/blog/2009/07/10/linq-to-sql-quirks-part-4-circular-references/</link>
		<comments>http://rainstorms.me.uk/blog/2009/07/10/linq-to-sql-quirks-part-4-circular-references/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 07:54:24 +0000</pubDate>
		<dc:creator>wizzard</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[.NET 3.5]]></category>
		<category><![CDATA[Circular Reference]]></category>
		<category><![CDATA[Insert]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[Linq to SQL]]></category>
		<category><![CDATA[Workarounds]]></category>

		<guid isPermaLink="false">http://rainstorms.me.uk/blog/?p=239</guid>
		<description><![CDATA[This entry is part of a series, Linq to SQL Quirks&#187; In a project that I am working on at the moment, I have a situation where I have a Person table and a Family table.  The Person table has a FamilyID field, which is a foreign key to the Families ID (primary key) field, [...]


No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<div class="hackadelic-series-info on-frontpage"><small>This entry is part of a series,  <a href="javascript:;" class="hackadelic-sliderButton"onclick="toggleSlider('#hackadelic-sliderPanel-2')" title="click to expand/collapse slider Linq to SQL Quirks">Linq to SQL Quirks&raquo;</a> <span class="hackadelic-sliderPanel concealed" id="hackadelic-sliderPanel-2"></span></small></div><p>In a project that I am working on at the moment, I have a situation where I have a Person table and a Family table.  The Person table has a FamilyID field, which is a foreign key to the Families ID (primary key) field, and the Family table has a DefaultPersonID, which is another foreign key back to Person to store the default contact for a family.</p>
<p>The problem is that if I create a new Person and Family with the Person being the DefaultContact, I get an InvalidOperationException thrown with a message &#8220;A cycle was detected in the set of changes&#8221;.  The problem is that Linq to SQL doesn&#8217;t know what to store first.  The only way that I have come up with to get around this is to do the following&#8230;</p>
<pre name="code" class="vb.net">
            If Person.ID = 0 AndAlso Not Person.Family Is Nothing Then

                Dim fam = Person.Family
                Person.Family = Nothing

                DBContext.SubmitChanges()
                Person.Family = fam

            End If

            DBContext.SubmitChanges()</pre>
<p>This works by breaking the circular reference, so that there is only a 1 way reference, then submitting to the database, and once submitted, restoring the removed reference and submitting changes again</p>
<div id="hackadelic-sliderNote-2" class="concealed">Entries in this series:<ol><li><a href="http://rainstorms.me.uk/blog/2009/06/23/linq-to-sql-quirks-part-1/">Linq to SQL Quirks Part 1: Implicit Inserts</a></li><li><a href="http://rainstorms.me.uk/blog/2009/06/23/linq-to-sql-quirks-part-2-deleteonsubmit-and-entity-not-attached/">Linq to SQL Quirks Part 2: DeleteOnSubmit and Entity not Attached</a></li><li><a href="http://rainstorms.me.uk/blog/2009/06/30/linq-to-sql-quirks-part-3-extension-to-get-around-the-delete-problem/">Linq to SQL Quirks Part 3 - Extension to Get Around the Delete Problem</a></li><li>Linq to SQL Quirks Part 4: Circular References</li></ol><span style="display: block; margin-top: 3px; font-size: 7px"><a href="http://hackadelic.com/solutions/wordpress/sliding-notes" title="Powered by Hackadelic Sliding Notes 1.6.5">Powered by Hackadelic Sliding Notes 1.6.5</a></span></div><!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark this post</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F07%2F10%2Flinq-to-sql-quirks-part-4-circular-references%2F&amp;title=Linq+to+SQL+Quirks+Part+4%3A+Circular+References" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F07%2F10%2Flinq-to-sql-quirks-part-4-circular-references%2F&amp;title=Linq+to+SQL+Quirks+Part+4%3A+Circular+References" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F07%2F10%2Flinq-to-sql-quirks-part-4-circular-references%2F&amp;title=Linq+to+SQL+Quirks+Part+4%3A+Circular+References" rel="nofollow" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F07%2F10%2Flinq-to-sql-quirks-part-4-circular-references%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://FriendSite.com/users/bookmarks/?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F07%2F10%2Flinq-to-sql-quirks-part-4-circular-references%2F&amp;t=Linq+to+SQL+Quirks+Part+4%3A+Circular+References" rel="nofollow" title="Add to&nbsp;FriendSite"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/friendsite.png" title="Add to&nbsp;FriendSite" alt="Add to&nbsp;FriendSite" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F07%2F10%2Flinq-to-sql-quirks-part-4-circular-references%2F&amp;title=Linq+to+SQL+Quirks+Part+4%3A+Circular+References" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F07%2F10%2Flinq-to-sql-quirks-part-4-circular-references%2F&amp;title=Linq+to+SQL+Quirks+Part+4%3A+Circular+References" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F07%2F10%2Flinq-to-sql-quirks-part-4-circular-references%2F&amp;title=Linq+to+SQL+Quirks+Part+4%3A+Circular+References" rel="nofollow" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F07%2F10%2Flinq-to-sql-quirks-part-4-circular-references%2F&amp;title=Linq+to+SQL+Quirks+Part+4%3A+Circular+References" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.shoutwire.com/?p=submit&amp;link=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F07%2F10%2Flinq-to-sql-quirks-part-4-circular-references%2F" rel="nofollow" title="Add to&nbsp;Shoutwire"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/shoutwire.png" title="Add to&nbsp;Shoutwire" alt="Add to&nbsp;Shoutwire" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F07%2F10%2Flinq-to-sql-quirks-part-4-circular-references%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F07%2F10%2Flinq-to-sql-quirks-part-4-circular-references%2F&amp;t=Linq+to+SQL+Quirks+Part+4%3A+Circular+References" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://rainstorms.me.uk/blog/2009/07/10/linq-to-sql-quirks-part-4-circular-references/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Linq to SQL Quirks Part 3 &#8211; Extension to Get Around the Delete Problem</title>
		<link>http://rainstorms.me.uk/blog/2009/06/30/linq-to-sql-quirks-part-3-extension-to-get-around-the-delete-problem/</link>
		<comments>http://rainstorms.me.uk/blog/2009/06/30/linq-to-sql-quirks-part-3-extension-to-get-around-the-delete-problem/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 21:34:35 +0000</pubDate>
		<dc:creator>wizzard</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[.NET 3.5]]></category>
		<category><![CDATA[Delete]]></category>
		<category><![CDATA[DeleteOnSubmit]]></category>
		<category><![CDATA[Extension Methods]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[Linq to SQL]]></category>
		<category><![CDATA[Workarounds]]></category>

		<guid isPermaLink="false">http://rainstorms.me.uk/blog/?p=181</guid>
		<description><![CDATA[This entry is part of a series, Linq to SQL Quirks&#187; My previous post about problems deleting can be partly handled with an extension method to the Linq to SQL Table(Of T) class with something like this&#8230; Public Sub DeleteOnSubmitOrDetach(Of T As Class)(ByVal table As System.Data.Linq.Table(Of T), ByVal o As T) Dim IDProperty = o.GetType.GetProperty("ID") [...]


No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<div class="hackadelic-series-info on-frontpage"><small>This entry is part of a series,  <a href="javascript:;" class="hackadelic-sliderButton"onclick="toggleSlider('#hackadelic-sliderPanel-4')" title="click to expand/collapse slider Linq to SQL Quirks">Linq to SQL Quirks&raquo;</a> <span class="hackadelic-sliderPanel concealed" id="hackadelic-sliderPanel-4"></span></small></div><p>My <a href="http://rainstorms.me.uk/blog/2009/06/23/linq-to-sql-quirks-part-2-deleteonsubmit-and-entity-not-attached/">previous post </a>about problems deleting can be partly handled with an extension method to the Linq to SQL Table(Of T) class with something like this&#8230;</p>
<pre name="code" class="vb.net">
         Public Sub DeleteOnSubmitOrDetach(Of T As Class)(ByVal table As System.Data.Linq.Table(Of T), ByVal o As T)
            Dim IDProperty = o.GetType.GetProperty("ID")
            If IDProperty Is Nothing Then
                Throw New System.MissingFieldException("Trying to delete object of type " &amp; GetType(T).Name &amp; " - does not have an ID field")
            End If
            If IDProperty.GetValue(o, New Object() {}) = 0 Then
                table.InsertOnSubmit(o)
            End If
            table.DeleteOnSubmit(o)
        End Sub
</pre>
<p>Note that you&#8217;ll need to import System.ComponentModel and  System.Reflection and possibly some others, and it assumes that you have an IDENTITY ID field by that name on all of your classes that you use this with.</p>
<div id="hackadelic-sliderNote-4" class="concealed">Entries in this series:<ol><li><a href="http://rainstorms.me.uk/blog/2009/06/23/linq-to-sql-quirks-part-1/">Linq to SQL Quirks Part 1: Implicit Inserts</a></li><li><a href="http://rainstorms.me.uk/blog/2009/06/23/linq-to-sql-quirks-part-2-deleteonsubmit-and-entity-not-attached/">Linq to SQL Quirks Part 2: DeleteOnSubmit and Entity not Attached</a></li><li>Linq to SQL Quirks Part 3 - Extension to Get Around the Delete Problem</li><li><a href="http://rainstorms.me.uk/blog/2009/07/10/linq-to-sql-quirks-part-4-circular-references/">Linq to SQL Quirks Part 4: Circular References</a></li></ol><span style="display: block; margin-top: 3px; font-size: 7px"><a href="http://hackadelic.com/solutions/wordpress/sliding-notes" title="Powered by Hackadelic Sliding Notes 1.6.5">Powered by Hackadelic Sliding Notes 1.6.5</a></span></div><!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark this post</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F30%2Flinq-to-sql-quirks-part-3-extension-to-get-around-the-delete-problem%2F&amp;title=Linq+to+SQL+Quirks+Part+3+%26%238211%3B+Extension+to+Get+Around+the+Delete+Problem" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F30%2Flinq-to-sql-quirks-part-3-extension-to-get-around-the-delete-problem%2F&amp;title=Linq+to+SQL+Quirks+Part+3+%26%238211%3B+Extension+to+Get+Around+the+Delete+Problem" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F30%2Flinq-to-sql-quirks-part-3-extension-to-get-around-the-delete-problem%2F&amp;title=Linq+to+SQL+Quirks+Part+3+%26%238211%3B+Extension+to+Get+Around+the+Delete+Problem" rel="nofollow" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F30%2Flinq-to-sql-quirks-part-3-extension-to-get-around-the-delete-problem%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://FriendSite.com/users/bookmarks/?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F30%2Flinq-to-sql-quirks-part-3-extension-to-get-around-the-delete-problem%2F&amp;t=Linq+to+SQL+Quirks+Part+3+%26%238211%3B+Extension+to+Get+Around+the+Delete+Problem" rel="nofollow" title="Add to&nbsp;FriendSite"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/friendsite.png" title="Add to&nbsp;FriendSite" alt="Add to&nbsp;FriendSite" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F30%2Flinq-to-sql-quirks-part-3-extension-to-get-around-the-delete-problem%2F&amp;title=Linq+to+SQL+Quirks+Part+3+%26%238211%3B+Extension+to+Get+Around+the+Delete+Problem" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F30%2Flinq-to-sql-quirks-part-3-extension-to-get-around-the-delete-problem%2F&amp;title=Linq+to+SQL+Quirks+Part+3+%26%238211%3B+Extension+to+Get+Around+the+Delete+Problem" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F30%2Flinq-to-sql-quirks-part-3-extension-to-get-around-the-delete-problem%2F&amp;title=Linq+to+SQL+Quirks+Part+3+%26%238211%3B+Extension+to+Get+Around+the+Delete+Problem" rel="nofollow" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F30%2Flinq-to-sql-quirks-part-3-extension-to-get-around-the-delete-problem%2F&amp;title=Linq+to+SQL+Quirks+Part+3+%26%238211%3B+Extension+to+Get+Around+the+Delete+Problem" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.shoutwire.com/?p=submit&amp;link=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F30%2Flinq-to-sql-quirks-part-3-extension-to-get-around-the-delete-problem%2F" rel="nofollow" title="Add to&nbsp;Shoutwire"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/shoutwire.png" title="Add to&nbsp;Shoutwire" alt="Add to&nbsp;Shoutwire" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F30%2Flinq-to-sql-quirks-part-3-extension-to-get-around-the-delete-problem%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F30%2Flinq-to-sql-quirks-part-3-extension-to-get-around-the-delete-problem%2F&amp;t=Linq+to+SQL+Quirks+Part+3+%26%238211%3B+Extension+to+Get+Around+the+Delete+Problem" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://rainstorms.me.uk/blog/2009/06/30/linq-to-sql-quirks-part-3-extension-to-get-around-the-delete-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linq to SQL Quirks Part 2: DeleteOnSubmit and Entity not Attached</title>
		<link>http://rainstorms.me.uk/blog/2009/06/23/linq-to-sql-quirks-part-2-deleteonsubmit-and-entity-not-attached/</link>
		<comments>http://rainstorms.me.uk/blog/2009/06/23/linq-to-sql-quirks-part-2-deleteonsubmit-and-entity-not-attached/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 09:30:14 +0000</pubDate>
		<dc:creator>wizzard</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[.NET 3.5]]></category>
		<category><![CDATA[Delete]]></category>
		<category><![CDATA[DeleteOnSubmit]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[Linq to SQL]]></category>

		<guid isPermaLink="false">http://rainstorms.me.uk/blog/?p=165</guid>
		<description><![CDATA[This entry is part of a series, Linq to SQL Quirks&#187; If you use an implicit insert on a new object and then decide that you don&#8217;t actually want it, you have a bit of a problem.  First of all, you need to remove the relationships that you created so that it doesn&#8217;t show up [...]


No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<div class="hackadelic-series-info on-frontpage"><small>This entry is part of a series,  <a href="javascript:;" class="hackadelic-sliderButton"onclick="toggleSlider('#hackadelic-sliderPanel-6')" title="click to expand/collapse slider Linq to SQL Quirks">Linq to SQL Quirks&raquo;</a> <span class="hackadelic-sliderPanel concealed" id="hackadelic-sliderPanel-6"></span></small></div><p>If you use an <a href="http://rainstorms.me.uk/blog/2009/06/23/linq-to-sql-quirks-part-1/">implicit insert</a> on a new object and then decide that you don&#8217;t actually want it, you have a bit of a problem.  First of all, you need to remove the relationships that you created so that it doesn&#8217;t show up in any places that it shouldn&#8217;t.  The problem with this is that Linq will still kind of (see below) have it marked for insertion, so if you call SubmitChanges without doing anything else, it will either still insert it, or if you&#8217;ve removed a relationship which relies on a non-nullable foreign key, you&#8217;ll get an error like</p>
<p>&#8220;An attempt was made to remove a relationship between a <strong><em>A</em></strong> and a <strong><em>B</em></strong>. However, one of the relationship&#8217;s foreign keys (<strong><em>A</em></strong>.<strong><em>B</em></strong>ID) cannot be set to null.&#8221;</p>
<p>Where A and B are the 2 appropriate Linq to SQL classes.</p>
<p>The next thing we need to do then is to make sure that Linq to SQL removes the item from the insert list.  The only way that I have found to do this is to call DeleteOnSubmit on the appropriate table.  The problem is that if we do that at this point, we get an InvalidOperationException with message &#8220;Cannot remove an entity that has not been attached.&#8221;</p>
<p>Apparently, Linq to SQL knows it is supposed to insert it, but it isn&#8217;t properly attached.  To get around this, we need to call InsertOnSubmit on the appropriate table <em>before</em> calling DeleteOnSubmit.</p>
<p>That&#8217;s all fine and dandy and works, as long as you are trying to delete something that <em>hasn&#8217;t</em> been inserted yet.  Normally, however, I use the same code whether it has been inserted or not, and of course if you call InsertOnSubmit on an entity that has already been inserted, you get an InvalidOperationException saying &#8220;Cannot add an entity that already exists.&#8221;.  Therefore, before you call InsertOnSubmit, you need to check if it actually has already been inserted.  Since I always have identity fields with the name ID on all my tables and Linq to SQL updates these when it does an insert, I normally just check that the ID is 0 before inserting.</p>
<p>The resulting steps that you need to solve the problem are therefore: -</p>
<ol>
<li>Remove the relationships from item</li>
<li>If the ID=0 then DataContext.Table.InsertOnSubmit(item)</li>
<li>DataContext.Table.DeleteOnSubmit(item)</li>
</ol>
<p>You shouldn&#8217;t actually have to call DataContext.SubmitChanges at this point &#8211; the whole point in the exercise is to mean it will be safe when you do later.</p>
<p>Alternatively, you can just throw away the datacontext without calling SubmitChanges, but I find that is rarely an option because there may be other data that needs submitting.</p>
<p>By the way, you need to do the first step of removing the relationships in order to make sure that none of your code accidentally tries to access the removed object as it will still be in memory as a related object until SubmitChanges is called otherwise and you could end up processing it when accessing entities related to an object that it is related to.</p>
<div id="hackadelic-sliderNote-6" class="concealed">Entries in this series:<ol><li><a href="http://rainstorms.me.uk/blog/2009/06/23/linq-to-sql-quirks-part-1/">Linq to SQL Quirks Part 1: Implicit Inserts</a></li><li>Linq to SQL Quirks Part 2: DeleteOnSubmit and Entity not Attached</li><li><a href="http://rainstorms.me.uk/blog/2009/06/30/linq-to-sql-quirks-part-3-extension-to-get-around-the-delete-problem/">Linq to SQL Quirks Part 3 - Extension to Get Around the Delete Problem</a></li><li><a href="http://rainstorms.me.uk/blog/2009/07/10/linq-to-sql-quirks-part-4-circular-references/">Linq to SQL Quirks Part 4: Circular References</a></li></ol><span style="display: block; margin-top: 3px; font-size: 7px"><a href="http://hackadelic.com/solutions/wordpress/sliding-notes" title="Powered by Hackadelic Sliding Notes 1.6.5">Powered by Hackadelic Sliding Notes 1.6.5</a></span></div><!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark this post</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F23%2Flinq-to-sql-quirks-part-2-deleteonsubmit-and-entity-not-attached%2F&amp;title=Linq+to+SQL+Quirks+Part+2%3A+DeleteOnSubmit+and+Entity+not+Attached" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F23%2Flinq-to-sql-quirks-part-2-deleteonsubmit-and-entity-not-attached%2F&amp;title=Linq+to+SQL+Quirks+Part+2%3A+DeleteOnSubmit+and+Entity+not+Attached" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F23%2Flinq-to-sql-quirks-part-2-deleteonsubmit-and-entity-not-attached%2F&amp;title=Linq+to+SQL+Quirks+Part+2%3A+DeleteOnSubmit+and+Entity+not+Attached" rel="nofollow" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F23%2Flinq-to-sql-quirks-part-2-deleteonsubmit-and-entity-not-attached%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://FriendSite.com/users/bookmarks/?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F23%2Flinq-to-sql-quirks-part-2-deleteonsubmit-and-entity-not-attached%2F&amp;t=Linq+to+SQL+Quirks+Part+2%3A+DeleteOnSubmit+and+Entity+not+Attached" rel="nofollow" title="Add to&nbsp;FriendSite"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/friendsite.png" title="Add to&nbsp;FriendSite" alt="Add to&nbsp;FriendSite" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F23%2Flinq-to-sql-quirks-part-2-deleteonsubmit-and-entity-not-attached%2F&amp;title=Linq+to+SQL+Quirks+Part+2%3A+DeleteOnSubmit+and+Entity+not+Attached" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F23%2Flinq-to-sql-quirks-part-2-deleteonsubmit-and-entity-not-attached%2F&amp;title=Linq+to+SQL+Quirks+Part+2%3A+DeleteOnSubmit+and+Entity+not+Attached" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F23%2Flinq-to-sql-quirks-part-2-deleteonsubmit-and-entity-not-attached%2F&amp;title=Linq+to+SQL+Quirks+Part+2%3A+DeleteOnSubmit+and+Entity+not+Attached" rel="nofollow" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F23%2Flinq-to-sql-quirks-part-2-deleteonsubmit-and-entity-not-attached%2F&amp;title=Linq+to+SQL+Quirks+Part+2%3A+DeleteOnSubmit+and+Entity+not+Attached" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.shoutwire.com/?p=submit&amp;link=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F23%2Flinq-to-sql-quirks-part-2-deleteonsubmit-and-entity-not-attached%2F" rel="nofollow" title="Add to&nbsp;Shoutwire"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/shoutwire.png" title="Add to&nbsp;Shoutwire" alt="Add to&nbsp;Shoutwire" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F23%2Flinq-to-sql-quirks-part-2-deleteonsubmit-and-entity-not-attached%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F23%2Flinq-to-sql-quirks-part-2-deleteonsubmit-and-entity-not-attached%2F&amp;t=Linq+to+SQL+Quirks+Part+2%3A+DeleteOnSubmit+and+Entity+not+Attached" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://rainstorms.me.uk/blog/2009/06/23/linq-to-sql-quirks-part-2-deleteonsubmit-and-entity-not-attached/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Linq to SQL Quirks Part 1: Implicit Inserts</title>
		<link>http://rainstorms.me.uk/blog/2009/06/23/linq-to-sql-quirks-part-1/</link>
		<comments>http://rainstorms.me.uk/blog/2009/06/23/linq-to-sql-quirks-part-1/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 09:01:54 +0000</pubDate>
		<dc:creator>wizzard</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[.NET 3.5]]></category>
		<category><![CDATA[Insert]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[Linq to SQL]]></category>

		<guid isPermaLink="false">http://rainstorms.me.uk/blog/?p=161</guid>
		<description><![CDATA[This entry is part of a series, Linq to SQL Quirks&#187; There are a few things that Linq to SQL can be a bit funny about that aren&#8217;t so obvious. First of all, there are what I call implicit inserts.  You might not have realised that you don&#8217;t actually need to explicitly call InsertOnSubmit on [...]


No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<div class="hackadelic-series-info on-frontpage"><small>This entry is part of a series,  <a href="javascript:;" class="hackadelic-sliderButton"onclick="toggleSlider('#hackadelic-sliderPanel-8')" title="click to expand/collapse slider Linq to SQL Quirks">Linq to SQL Quirks&raquo;</a> <span class="hackadelic-sliderPanel concealed" id="hackadelic-sliderPanel-8"></span></small></div><p>There are a few things that Linq to SQL can be a bit funny about that aren&#8217;t so obvious.</p>
<p>First of all, there are what I call implicit inserts.  You might not have realised that you don&#8217;t actually need to explicitly call InsertOnSubmit on a table for Linq to SQL to do the insert as long as you have created a relationship to an object which already exists in the database.  Linq to SQL will automatically insert the new object on the next SubmitChanges call.</p>
<div id="hackadelic-sliderNote-8" class="concealed">Entries in this series:<ol><li>Linq to SQL Quirks Part 1: Implicit Inserts</li><li><a href="http://rainstorms.me.uk/blog/2009/06/23/linq-to-sql-quirks-part-2-deleteonsubmit-and-entity-not-attached/">Linq to SQL Quirks Part 2: DeleteOnSubmit and Entity not Attached</a></li><li><a href="http://rainstorms.me.uk/blog/2009/06/30/linq-to-sql-quirks-part-3-extension-to-get-around-the-delete-problem/">Linq to SQL Quirks Part 3 - Extension to Get Around the Delete Problem</a></li><li><a href="http://rainstorms.me.uk/blog/2009/07/10/linq-to-sql-quirks-part-4-circular-references/">Linq to SQL Quirks Part 4: Circular References</a></li></ol><span style="display: block; margin-top: 3px; font-size: 7px"><a href="http://hackadelic.com/solutions/wordpress/sliding-notes" title="Powered by Hackadelic Sliding Notes 1.6.5">Powered by Hackadelic Sliding Notes 1.6.5</a></span></div><!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark this post</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F23%2Flinq-to-sql-quirks-part-1%2F&amp;title=Linq+to+SQL+Quirks+Part+1%3A+Implicit+Inserts" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F23%2Flinq-to-sql-quirks-part-1%2F&amp;title=Linq+to+SQL+Quirks+Part+1%3A+Implicit+Inserts" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F23%2Flinq-to-sql-quirks-part-1%2F&amp;title=Linq+to+SQL+Quirks+Part+1%3A+Implicit+Inserts" rel="nofollow" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F23%2Flinq-to-sql-quirks-part-1%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://FriendSite.com/users/bookmarks/?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F23%2Flinq-to-sql-quirks-part-1%2F&amp;t=Linq+to+SQL+Quirks+Part+1%3A+Implicit+Inserts" rel="nofollow" title="Add to&nbsp;FriendSite"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/friendsite.png" title="Add to&nbsp;FriendSite" alt="Add to&nbsp;FriendSite" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F23%2Flinq-to-sql-quirks-part-1%2F&amp;title=Linq+to+SQL+Quirks+Part+1%3A+Implicit+Inserts" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F23%2Flinq-to-sql-quirks-part-1%2F&amp;title=Linq+to+SQL+Quirks+Part+1%3A+Implicit+Inserts" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F23%2Flinq-to-sql-quirks-part-1%2F&amp;title=Linq+to+SQL+Quirks+Part+1%3A+Implicit+Inserts" rel="nofollow" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F23%2Flinq-to-sql-quirks-part-1%2F&amp;title=Linq+to+SQL+Quirks+Part+1%3A+Implicit+Inserts" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.shoutwire.com/?p=submit&amp;link=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F23%2Flinq-to-sql-quirks-part-1%2F" rel="nofollow" title="Add to&nbsp;Shoutwire"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/shoutwire.png" title="Add to&nbsp;Shoutwire" alt="Add to&nbsp;Shoutwire" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F23%2Flinq-to-sql-quirks-part-1%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F06%2F23%2Flinq-to-sql-quirks-part-1%2F&amp;t=Linq+to+SQL+Quirks+Part+1%3A+Implicit+Inserts" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://rainstorms.me.uk/blog/2009/06/23/linq-to-sql-quirks-part-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

