<?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>Florent Clairambault &#187; ADO.Net</title>
	<atom:link href="http://florent.clairambault.fr/tag/ado-net/feed" rel="self" type="application/rss+xml" />
	<link>http://florent.clairambault.fr</link>
	<description></description>
	<lastBuildDate>Sat, 04 Feb 2012 19:56:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4-alpha-19719</generator>
		<item>
		<title>LinQ to Entities on ADO.Net vs LinQ to SQL</title>
		<link>http://florent.clairambault.fr/linq-to-entities-on-ado-net-vs-linq-to-sql?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=linq-to-entities-on-ado-net-vs-linq-to-sql</link>
		<comments>http://florent.clairambault.fr/linq-to-entities-on-ado-net-vs-linq-to-sql#comments</comments>
		<pubDate>Sun, 04 Oct 2009 20:36:09 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[ADO.Net]]></category>
		<category><![CDATA[C# .Net]]></category>
		<category><![CDATA[LinQ]]></category>
		<category><![CDATA[LinQ to entities]]></category>
		<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=1723</guid>
		<description><![CDATA[To make it short : LinQ to SQL only works with SQL Server but it&#8217;s working great. It&#8217;s simple, supports all LinQ operations and optimizes the generated SQL queries. LinQ to Entities on ADO.Net works with lots of database but it doesn&#8217;t behave like LinQ to SQL and doesn&#8217;t support some key LinQ features. Now [...]]]></description>
			<content:encoded><![CDATA[<p>To make it short :</p>
<ul>
<li>LinQ to SQL only works with SQL Server but it&#8217;s working great. It&#8217;s simple, supports all LinQ operations and optimizes the generated SQL queries.</li>
<li>LinQ to Entities on ADO.Net works with lots of database but it doesn&#8217;t behave like LinQ to SQL and doesn&#8217;t support some key LinQ features.</li>
</ul>
<p>Now the long story :<br />
For the last project I&#8217;ve been working on, we wanted to use LinQ and still be able to switch to one database to an other (MSSQL to MySQL for instance). So we decided we would use LinQ to entity. The generated object are roughly the same, the code to Create/Read/Update/Delete data is roughly the same. So we were quite happy.</p>
<p><strong>Deffered loading</strong><br />
When you do a LinQ request, the data from the associated table isn&#8217;t fetched. There&#8217;s in fact no other way, as you would get your whole database if you always fetched all the associated objects of your current query.<br />
Deferred loading consists in loading the data coming from an associated table when you request it (when you access your object property).<br />
Eager loading consists in loading the data when you request it.</p>
<p>In LinQ to entities, deferred loading isn&#8217;t supported. You have to use eager loading with the .Include(&#8220;Property&#8221;) LinQ method.</p>

<div class="wp_codebox"><table><tr id="p17239"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1723code9"><pre class="csharp" style="font-family:monospace;">var query <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">from</span> u <span style="color: #0600FF; font-weight: bold;">in</span> Db<span style="color: #008000;">.</span><span style="color: #0000FF;">User</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Include</span><span style="color: #008000;">&#40;</span> <span style="color: #666666;">&quot;Group&quot;</span> <span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">select</span> u<span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>But in fact, you can do some deferred loading very easily in LinQ to Entities :</p>

<div class="wp_codebox"><table><tr id="p172310"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p1723code10"><pre class="csharp" style="font-family:monospace;">var query <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">from</span> u <span style="color: #0600FF; font-weight: bold;">in</span> Db<span style="color: #008000;">.</span><span style="color: #0000FF;">User</span> <span style="color: #0600FF; font-weight: bold;">select</span> u<span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">foreach</span><span style="color: #008000;">&#40;</span> var user <span style="color: #0600FF; font-weight: bold;">in</span> query <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span> <span style="color: #008000;">!</span> user<span style="color: #008000;">.</span><span style="color: #0000FF;">GroupReference</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsLoaded</span> <span style="color: #008000;">&#41;</span>     
        user<span style="color: #008000;">.</span><span style="color: #0000FF;">GroupReference</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Load</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span> <span style="color: #666666;">&quot;User={0}, Group={1}&quot;</span>, user<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span>, user<span style="color: #008000;">.</span><span style="color: #0000FF;">Group</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p><strong>Non supported LinQ key features</strong><br />
Well, now I only want to select the users 1, 2, 3 :</p>

<div class="wp_codebox"><table><tr id="p172311"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p1723code11"><pre class="csharp" style="font-family:monospace;">var users <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#123;</span> <span style="color: #FF0000;">1</span>, <span style="color: #FF0000;">2</span>, <span style="color: #FF0000;">3</span> <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
var query <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">from</span> u <span style="color: #0600FF; font-weight: bold;">in</span> Db<span style="color: #008000;">.</span><span style="color: #0000FF;">User</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Include</span><span style="color: #008000;">&#40;</span> <span style="color: #666666;">&quot;Group&quot;</span> <span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">where</span> users<span style="color: #008000;">.</span><span style="color: #0000FF;">Contains</span><span style="color: #008000;">&#40;</span> u<span style="color: #008000;">.</span><span style="color: #0000FF;">UserId</span> <span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">select</span> u<span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>Oups, that would work on LinQ to SQL, but on LinQ to Entities it doesn&#8217;t. LinQ to Entities doesn&#8217;t support the .Contains or .Any methods. (Note : these methods are supported since .Net 4.0, see below).</p>
<p>There&#8217;s in fact a solution but it requires your request to be typed in a method based LinQ Query :</p>

<div class="wp_codebox"><table><tr id="p172312"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code" id="p1723code12"><pre class="csharp" style="font-family:monospace;">		<span style="color: #0600FF; font-weight: bold;">static</span> Expression<span style="color: #008000;">&lt;</span>Func<span style="color: #008000;">&lt;</span>TElement, <span style="color: #6666cc; font-weight: bold;">bool</span><span style="color: #008000;">&gt;&gt;</span> BuildContainsExpression<span style="color: #008000;">&lt;</span>TElement, TValue<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span>
			Expression<span style="color: #008000;">&lt;</span>Func<span style="color: #008000;">&lt;</span>TElement, TValue<span style="color: #008000;">&gt;&gt;</span> valueSelector,
			IEnumerable<span style="color: #008000;">&lt;</span>TValue<span style="color: #008000;">&gt;</span> values
		<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
			<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">==</span> valueSelector <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">throw</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> ArgumentNullException<span style="color: #008000;">&#40;</span> <span style="color: #666666;">&quot;valueSelector&quot;</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
			<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">==</span> values <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">throw</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> ArgumentNullException<span style="color: #008000;">&#40;</span> <span style="color: #666666;">&quot;values&quot;</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
			ParameterExpression p <span style="color: #008000;">=</span> valueSelector<span style="color: #008000;">.</span><span style="color: #0000FF;">Parameters</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Single</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
			<span style="color: #008080; font-style: italic;">// p =&gt; valueSelector(p) == values[0] || valueSelector(p) == ...</span>
			<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span> <span style="color: #008000;">!</span>values<span style="color: #008000;">.</span><span style="color: #0000FF;">Any</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
				<span style="color: #0600FF; font-weight: bold;">return</span> e <span style="color: #008000;">=&gt;</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
			<span style="color: #008000;">&#125;</span>
			var equals <span style="color: #008000;">=</span> values<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Select</span><span style="color: #008000;">&#40;</span> value <span style="color: #008000;">=&gt;</span> <span style="color: #008000;">&#40;</span>Expression<span style="color: #008000;">&#41;</span> Expression<span style="color: #008000;">.</span><span style="color: #0000FF;">Equal</span><span style="color: #008000;">&#40;</span> valueSelector<span style="color: #008000;">.</span><span style="color: #0000FF;">Body</span>, Expression<span style="color: #008000;">.</span><span style="color: #0000FF;">Constant</span><span style="color: #008000;">&#40;</span> value, <a href="http://www.google.com/search?q=typeof+msdn.microsoft.com"><span style="color: #008000;">typeof</span></a><span style="color: #008000;">&#40;</span> TValue <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
			var body <span style="color: #008000;">=</span> equals<span style="color: #008000;">.</span><span style="color: #0000FF;">Aggregate</span><span style="color: #008000;">&lt;</span>Expression<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#40;</span> accumulate, equal <span style="color: #008000;">&#41;</span> <span style="color: #008000;">=&gt;</span> Expression<span style="color: #008000;">.</span><span style="color: #0000FF;">Or</span><span style="color: #008000;">&#40;</span> accumulate, equal <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
			<span style="color: #0600FF; font-weight: bold;">return</span> Expression<span style="color: #008000;">.</span><span style="color: #0000FF;">Lambda</span><span style="color: #008000;">&lt;</span>Func<span style="color: #008000;">&lt;</span>TElement, <span style="color: #6666cc; font-weight: bold;">bool</span><span style="color: #008000;">&gt;&gt;</span><span style="color: #008000;">&#40;</span> body, p <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
		<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>And then it looks like this :</p>

<div class="wp_codebox"><table><tr id="p172313"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p1723code13"><pre class="csharp" style="font-family:monospace;">var users <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#123;</span> <span style="color: #FF0000;">1</span>, <span style="color: #FF0000;">2</span>, <span style="color: #FF0000;">3</span> <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
var query <span style="color: #008000;">=</span> Db<span style="color: #008000;">.</span><span style="color: #0000FF;">User</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Where</span><span style="color: #008000;">&#40;</span> BuildContainsExpression<span style="color: #008000;">&lt;</span>User, <span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span> u<span style="color: #008000;">=&gt;</span> u<span style="color: #008000;">.</span><span style="color: #0000FF;">UserId</span>, users <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>Now, let&#8217;s say you want to use the Include method in the method based query. Well you can&#8217;t. But <a href="http://community.visual-basic.it/alessandroenglish/archive/2009/01/19/24647.aspx">someone</a> added an extension method to do this :</p>

<div class="wp_codebox"><table><tr id="p172314"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p1723code14"><pre class="csharp" style="font-family:monospace;">	<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">class</span> ObjectQueryExtension <span style="color: #008000;">&#123;</span>
		<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> ObjectQuery<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span> Include<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span> <span style="color: #0600FF; font-weight: bold;">this</span> ObjectQuery<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span> mainQuery, Expression<span style="color: #008000;">&lt;</span>Func<span style="color: #008000;">&lt;</span>T, <span style="color: #6666cc; font-weight: bold;">object</span><span style="color: #008000;">&gt;&gt;</span> subSelector <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
			<span style="color: #0600FF; font-weight: bold;">return</span> mainQuery<span style="color: #008000;">.</span><span style="color: #0000FF;">Include</span><span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#40;</span> subSelector<span style="color: #008000;">.</span><span style="color: #0000FF;">Body</span> <span style="color: #0600FF; font-weight: bold;">as</span> MemberExpression <span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Member</span> <span style="color: #0600FF; font-weight: bold;">as</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Reflection</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">PropertyInfo</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
		<span style="color: #008000;">&#125;</span>
	<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>You have to use it like that :</p>

<div class="wp_codebox"><table><tr id="p172315"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p1723code15"><pre class="csharp" style="font-family:monospace;">var users <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#123;</span> <span style="color: #FF0000;">1</span>, <span style="color: #FF0000;">2</span>, <span style="color: #FF0000;">3</span> <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
var query <span style="color: #008000;">=</span> Db<span style="color: #008000;">.</span><span style="color: #0000FF;">User</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Include</span><span style="color: #008000;">&#40;</span> u <span style="color: #008000;">=&gt;</span> u<span style="color: #008000;">.</span><span style="color: #0000FF;">Group</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Where</span><span style="color: #008000;">&#40;</span> BuildContainsExpression<span style="color: #008000;">&lt;</span>User, <span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span> u<span style="color: #008000;">=&gt;</span> u<span style="color: #008000;">.</span><span style="color: #0000FF;">UserId</span>, users <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>I hope this could help you start or switch to LinQ to entities in case you hesitated.</p>
<p><strong>LEFT JOIN in LinQ to entities</strong><br />
You know how LEFT JOIN works in LinQ, you need a join and DefaultIfEmpty :</p>

<div class="wp_codebox"><table><tr id="p172316"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code" id="p1723code16"><pre class="csharp" style="font-family:monospace;">var query <span style="color: #008000;">=</span> 
<span style="color: #0600FF; font-weight: bold;">from</span> user <span style="color: #0600FF; font-weight: bold;">in</span> Db<span style="color: #008000;">.</span><span style="color: #0000FF;">User</span>
join preferredSuperHero <span style="color: #0600FF; font-weight: bold;">in</span> Db<span style="color: #008000;">.</span><span style="color: #0000FF;">User_Parameter</span> on 
	<a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #008000;">&#123;</span> 
		UserId <span style="color: #008000;">=</span> user<span style="color: #008000;">.</span><span style="color: #0000FF;">UserId</span>, 
		ParamName <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;PreferredSuperHero&quot;</span> 
	<span style="color: #008000;">&#125;</span> 
	equals <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #008000;">&#123;</span> 
		UserId  <span style="color: #008000;">=</span> preferredSuperHero<span style="color: #008000;">.</span><span style="color: #0000FF;">UderId</span>, 
		ParamName <span style="color: #008000;">=</span> preferredSuperHero<span style="color: #008000;">.</span><span style="color: #0000FF;">Parameter</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> 
	<span style="color: #008000;">&#125;</span>
	into joinedPreferredSuperHero
<span style="color: #0600FF; font-weight: bold;">from</span> preferredSuperHero <span style="color: #0600FF; font-weight: bold;">in</span> joinedPreferredSuperHero<span style="color: #008000;">.</span><span style="color: #0000FF;">DefaultIfEmpty</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
orderby user<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span>
<span style="color: #0600FF; font-weight: bold;">select</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #008000;">&#123;</span> User <span style="color: #008000;">=</span> user, PreferredSuperHero <span style="color: #008000;">=</span> preferredSuperHero <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>Except&#8230; DefaultIfEmpty doesn&#8217;t works with LinQ-to-entities. You generally can find other solutions, but it will add some difficulties. (Note : this method is supported since .Net 4.0, see below).</p>
<p><strong>Check what is supported</strong><br />
In <a href="http://msdn.microsoft.com/en-us/library/bb738638.aspx">this page</a>, you can check if the methods you might require are available. The two non supported methods I talked about are supported with the .Net 4.0 (currently only available in bêta). So most of the problem related to the missing methods will be solved.</p>
<p><strong>About switching from one base to an other</strong><br />
Switching from one base to the other can be pretty easy if you have the right conversion tool. If not, you have to do all the work yourself. If you wish to switch to MySQL for instance, you can use the MySQL conversion tool. It converts the table structure, the keys, the foreign keys, the indexes and the data from MSSQL to MySQL.</p>
<p>After that, the generated code is exactly the same but I&#8217;m <a href="http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/1a5ca25a-8d92-4533-864a-24e8be823a44">not sure you can use one EDMX model file for multiple databases</a>. It might work by using an external SSDL (instead of an resource embedded file) that you select in the connection String for each database. But I haven&#8217;t tested it yet.</p>
<p><strong>My little conclusion</strong><br />
LinQ to entities works pretty well. The non automatic deferred loading is really not a problem, especially since it totally kills performances (it fetches data row by row instead of loading everything from a single request). My biggest problem was the lacking support of some LinQ methods, you can solve most of them easily (it just makes an ugly code).</p>
<p>With the .Net 3.5, I think the multi-database feature offered by LinQ to Entities on ADO.Net worth this little extra effort to make it work. But if you don&#8217;t care about this (because you only build a little short-life program), you should stick to LiNQ to (MS)SQL as everything works instantly on it.</p>
<p>With the .Net 4.0, LinQ to entities becomes even more interesting. And that&#8217;s a reason to start using it with the .Net 3.5 framework.</p>
<p><strong>Sources :</strong></p>
<ul>
<li><a href="http://blogs.msdn.com/adonet/archive/2008/10/16/migrating-from-linq-to-sql-to-entity-framework-deferred-loading.aspx">ADO.NET team blog</a></li>
<li><a href="http://social.msdn.microsoft.com/forums/en-US/adodotnetentityframework/thread/095745fe-dcf0-4142-b684-b7e4a1ab59f0/">MSDN Forums</a>
<li><a href="http://community.visual-basic.it/alessandroenglish/archive/2009/01/19/24647.aspx">Matthieu MEZIL</a></li>
<li><a href="http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/1a5ca25a-8d92-4533-864a-24e8be823a44">MSDN Forums</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/linq-to-entities-on-ado-net-vs-linq-to-sql/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 1/19 queries in 0.008 seconds using disk: basic
Object Caching 622/659 objects using disk: basic

Served from: florent.clairambault.fr @ 2012-02-07 10:50:19 -->
