<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: LINQ-to-Entities: The Blackberry Storm of ORMs?</title>
	<atom:link href="http://www.hackification.com/2008/12/03/linq-to-entities-the-blackberry-storm-of-orms/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hackification.com/2008/12/03/linq-to-entities-the-blackberry-storm-of-orms/</link>
	<description>Rediscover the joy of coding.</description>
	<lastBuildDate>Sun, 07 Mar 2010 03:07:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jim Wooley</title>
		<link>http://www.hackification.com/2008/12/03/linq-to-entities-the-blackberry-storm-of-orms/comment-page-1/#comment-3991</link>
		<dc:creator>Jim Wooley</dc:creator>
		<pubDate>Thu, 30 Apr 2009 19:53:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.hackification.com/?p=60#comment-3991</guid>
		<description>On your example #2, the better option with LINQ to SQL is to use the Contains clause which translates to the TSQL IN statement. Unfortunately, EF doesn&#039;t support Contains at this point. 

That being said, your construct is dangerous from a defered execution perspective in that it is easy for the expression tree to evaluate each of the variables you are adding in on your loop as a reference back to the same underlying value. Because of this, VB actually provides a compiler warning to keep you from using variables like this inside of your loops. Instead, create a local place holder and refer to that when using foreach loops. It doesn&#039;t factor as much if you use indexed arrays as you did in your example. However, if you use a local variable, both LINQ to SQL and EF will perform the same way and you avoid the potential for defered execution errors. See if the following modification to your code works with EF for you.

using( var data = new LinqToEntities() )
{
  var names = new[] { &quot;Alice&quot;, &quot;Bob&quot;, &quot;Dummy&quot; };

  for( var i = 0; i &lt; names.Length; ++i )
  {
    string Name = names[i};
    var customers = from c in data.Customers
                    where c.Name == Name
                    select c;

    // Do something with the customers found.
  }
}</description>
		<content:encoded><![CDATA[<p>On your example #2, the better option with LINQ to SQL is to use the Contains clause which translates to the TSQL IN statement. Unfortunately, EF doesn&#8217;t support Contains at this point. </p>
<p>That being said, your construct is dangerous from a defered execution perspective in that it is easy for the expression tree to evaluate each of the variables you are adding in on your loop as a reference back to the same underlying value. Because of this, VB actually provides a compiler warning to keep you from using variables like this inside of your loops. Instead, create a local place holder and refer to that when using foreach loops. It doesn&#8217;t factor as much if you use indexed arrays as you did in your example. However, if you use a local variable, both LINQ to SQL and EF will perform the same way and you avoid the potential for defered execution errors. See if the following modification to your code works with EF for you.</p>
<p>using( var data = new LinqToEntities() )<br />
{<br />
  var names = new[] { &#8220;Alice&#8221;, &#8220;Bob&#8221;, &#8220;Dummy&#8221; };</p>
<p>  for( var i = 0; i &lt; names.Length; ++i )<br />
  {<br />
    string Name = names[i};<br />
    var customers = from c in data.Customers<br />
                    where c.Name == Name<br />
                    select c;</p>
<p>    // Do something with the customers found.<br />
  }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee Dumond</title>
		<link>http://www.hackification.com/2008/12/03/linq-to-entities-the-blackberry-storm-of-orms/comment-page-1/#comment-289</link>
		<dc:creator>Lee Dumond</dc:creator>
		<pubDate>Mon, 15 Dec 2008 05:38:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.hackification.com/?p=60#comment-289</guid>
		<description>@ Jon Kruger:

I don&#039;t really know if I&#039;d call these examples of the EF &quot;failures&quot;. Understanding that the EF was developed by the ADO team and L2S by the language team, it was probably inevitable that these inconsistencies would crop up.

What I think is the real shame here is that MS seems to want to &quot;obsolete&quot; L2S in favor of the EF. Why? Instead, why not bring both under the purview of the ADO team, cross-port the best concepts from both projects, iron out the inconsistencies with things like deferred loading, and keep both? I do believe the EF has its place, but as the article points out, L2S is an awesome, lightweight framework that is probably better suited to the majority of non enterprise-level projects.</description>
		<content:encoded><![CDATA[<p>@ Jon Kruger:</p>
<p>I don&#8217;t really know if I&#8217;d call these examples of the EF &#8220;failures&#8221;. Understanding that the EF was developed by the ADO team and L2S by the language team, it was probably inevitable that these inconsistencies would crop up.</p>
<p>What I think is the real shame here is that MS seems to want to &#8220;obsolete&#8221; L2S in favor of the EF. Why? Instead, why not bring both under the purview of the ADO team, cross-port the best concepts from both projects, iron out the inconsistencies with things like deferred loading, and keep both? I do believe the EF has its place, but as the article points out, L2S is an awesome, lightweight framework that is probably better suited to the majority of non enterprise-level projects.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Kruger</title>
		<link>http://www.hackification.com/2008/12/03/linq-to-entities-the-blackberry-storm-of-orms/comment-page-1/#comment-287</link>
		<dc:creator>Jon Kruger</dc:creator>
		<pubDate>Sat, 13 Dec 2008 03:30:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.hackification.com/?p=60#comment-287</guid>
		<description>Absolutely amazing that the Entity Framework fails on such simple stuff.  I don&#039;t want to know how bad it fails on the complicated stuff.  

I see no reason why I should abandon NHibernate for the Entity Framework and I can&#039;t see how Entity Framework will ever be able to catch up when I haven&#039;t heard anyone (outside of the EF team) say anything good about it.  

Imagine where we would be now if they EF team had instead spent their time improving NHibernate or LINQ to SQL instead of building EF?</description>
		<content:encoded><![CDATA[<p>Absolutely amazing that the Entity Framework fails on such simple stuff.  I don&#8217;t want to know how bad it fails on the complicated stuff.  </p>
<p>I see no reason why I should abandon NHibernate for the Entity Framework and I can&#8217;t see how Entity Framework will ever be able to catch up when I haven&#8217;t heard anyone (outside of the EF team) say anything good about it.  </p>
<p>Imagine where we would be now if they EF team had instead spent their time improving NHibernate or LINQ to SQL instead of building EF?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gius</title>
		<link>http://www.hackification.com/2008/12/03/linq-to-entities-the-blackberry-storm-of-orms/comment-page-1/#comment-283</link>
		<dc:creator>gius</dc:creator>
		<pubDate>Thu, 11 Dec 2008 18:41:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.hackification.com/?p=60#comment-283</guid>
		<description>There is another advantage of L2S over EF - in L2S, you can group by entity (&quot;group by order.Customer&quot;), in EF you cannot (you have to use &quot;group by order.Customer.ID, order.Customer.Name, order.Customer...&quot;, etc.)</description>
		<content:encoded><![CDATA[<p>There is another advantage of L2S over EF &#8211; in L2S, you can group by entity (&#8220;group by order.Customer&#8221;), in EF you cannot (you have to use &#8220;group by order.Customer.ID, order.Customer.Name, order.Customer&#8230;&#8221;, etc.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin</title>
		<link>http://www.hackification.com/2008/12/03/linq-to-entities-the-blackberry-storm-of-orms/comment-page-1/#comment-281</link>
		<dc:creator>Martin</dc:creator>
		<pubDate>Thu, 11 Dec 2008 10:30:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.hackification.com/?p=60#comment-281</guid>
		<description>Actually the most current version of Linq-To-SQL doesn&#039;t support .SingleOrDefault anymore...
So EF is consistent there...</description>
		<content:encoded><![CDATA[<p>Actually the most current version of Linq-To-SQL doesn&#8217;t support .SingleOrDefault anymore&#8230;<br />
So EF is consistent there&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee Dumond</title>
		<link>http://www.hackification.com/2008/12/03/linq-to-entities-the-blackberry-storm-of-orms/comment-page-1/#comment-280</link>
		<dc:creator>Lee Dumond</dc:creator>
		<pubDate>Thu, 11 Dec 2008 01:08:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.hackification.com/?p=60#comment-280</guid>
		<description>I am currently tech-editing a book on the Entity Framework, and wrote one on LINQ to SQL, so I can feel your pain -- because I&#039;m feeling it too.

I was one of those, like many others, who thought the EF was going to be really, really revolutionary. While I always kinda understood that L2S was the &quot;dime-bag&quot; to get us all hooked on LINQ and therefore buy straight into the EF, what I have come to realize in the course of this current project is that for probably 90% of projects, the Entity Framework is the equivalent of watering a houseplant with a firehose. Just too much. In these cases, L2S is just the kind of lightweight, easy-to-handle framework you need.

To be fair, the lack of support for implicit deferred loading is not such a big deal. A lot of folks actually prefer the EF way; having gripes with the way L2S does it, saying that they don&#039;t like the fact the L2S issues db calls behind the scenes -- though I would answer that really, why should you *care* when the data gets fetched, as long as it does? But ultimately, implicit vs. explicit deferred loading is kind of a potato-potahto thing. There are good arguments for both. I, however, do agree that it&#039;d be nice if they would just pick one direction and go with it.

I wholeheartedly agree with the rest of your points though. I suppose the only consolation is that Microsoft seems pretty committed to the EF and that it should improve over time. We shall see.</description>
		<content:encoded><![CDATA[<p>I am currently tech-editing a book on the Entity Framework, and wrote one on LINQ to SQL, so I can feel your pain &#8212; because I&#8217;m feeling it too.</p>
<p>I was one of those, like many others, who thought the EF was going to be really, really revolutionary. While I always kinda understood that L2S was the &#8220;dime-bag&#8221; to get us all hooked on LINQ and therefore buy straight into the EF, what I have come to realize in the course of this current project is that for probably 90% of projects, the Entity Framework is the equivalent of watering a houseplant with a firehose. Just too much. In these cases, L2S is just the kind of lightweight, easy-to-handle framework you need.</p>
<p>To be fair, the lack of support for implicit deferred loading is not such a big deal. A lot of folks actually prefer the EF way; having gripes with the way L2S does it, saying that they don&#8217;t like the fact the L2S issues db calls behind the scenes &#8212; though I would answer that really, why should you *care* when the data gets fetched, as long as it does? But ultimately, implicit vs. explicit deferred loading is kind of a potato-potahto thing. There are good arguments for both. I, however, do agree that it&#8217;d be nice if they would just pick one direction and go with it.</p>
<p>I wholeheartedly agree with the rest of your points though. I suppose the only consolation is that Microsoft seems pretty committed to the EF and that it should improve over time. We shall see.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ron</title>
		<link>http://www.hackification.com/2008/12/03/linq-to-entities-the-blackberry-storm-of-orms/comment-page-1/#comment-279</link>
		<dc:creator>Ron</dc:creator>
		<pubDate>Wed, 10 Dec 2008 22:13:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.hackification.com/?p=60#comment-279</guid>
		<description>There&#039;s another significant problem I ran into with the EF, which made it a dealbreaker for me. It refuses to expose foreign keys. They decided to be &quot;holistic&quot; (actual quote from MS!) and stick to the idea that this is fully object-oriented and not relational in the least. So therefore, code like this simple L2S code:

Product chai = db.Products.Where(p =&gt; p.ProductName == &quot;Chai&quot;).Single(); 
chai.CategoryID = 1; 
db.SubmitChanges();
 
Will not work, if CategoryID is a foreign key into the category table. Instead, in order to set the category of an object, you must actually waste time with another database call to retrieve the category object, and then set it:
 
Product chai = db.Products.Where(p =&gt; p.ProductName == &quot;Chai&quot;).First();
Category beverages = db.Categories.Where(c =&gt; c.CategoryName == &quot;Beverages&quot;).First();
chai.Category = beverages;

Unbelievable.

There are many blogs out there which seem to show that the SQL queries that EF generates are remarkably slower than L2S queries as well. I haven&#039;t tried this out for myself, but it wouldn&#039;t surprise me. If MS decides that L2S is dead, we may just have to reverse engineer it and make it ourselves. EF is a complete joke.</description>
		<content:encoded><![CDATA[<p>There&#8217;s another significant problem I ran into with the EF, which made it a dealbreaker for me. It refuses to expose foreign keys. They decided to be &#8220;holistic&#8221; (actual quote from MS!) and stick to the idea that this is fully object-oriented and not relational in the least. So therefore, code like this simple L2S code:</p>
<p>Product chai = db.Products.Where(p =&gt; p.ProductName == &#8220;Chai&#8221;).Single();<br />
chai.CategoryID = 1;<br />
db.SubmitChanges();</p>
<p>Will not work, if CategoryID is a foreign key into the category table. Instead, in order to set the category of an object, you must actually waste time with another database call to retrieve the category object, and then set it:</p>
<p>Product chai = db.Products.Where(p =&gt; p.ProductName == &#8220;Chai&#8221;).First();<br />
Category beverages = db.Categories.Where(c =&gt; c.CategoryName == &#8220;Beverages&#8221;).First();<br />
chai.Category = beverages;</p>
<p>Unbelievable.</p>
<p>There are many blogs out there which seem to show that the SQL queries that EF generates are remarkably slower than L2S queries as well. I haven&#8217;t tried this out for myself, but it wouldn&#8217;t surprise me. If MS decides that L2S is dead, we may just have to reverse engineer it and make it ourselves. EF is a complete joke.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Warren</title>
		<link>http://www.hackification.com/2008/12/03/linq-to-entities-the-blackberry-storm-of-orms/comment-page-1/#comment-270</link>
		<dc:creator>Matt Warren</dc:creator>
		<pubDate>Wed, 10 Dec 2008 05:04:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.hackification.com/?p=60#comment-270</guid>
		<description>The strange thing that is happening with EF is not the lack of lazy loading, its that the data showed up magically after you queried for all orders. The reason it showed no orders to begin with was because there is no implicit lazy loading, so the collection is empty until you explicity call load. Then when you queried it again, after looking at all orders, suddenly there were orders loaded; the collection changed on its own. This happens because EF allows merge behaviors ala DataSet when queries are run. Any entities that are retrieved are put into the cache and if related entities are found also in the cache they are wired together. So, simply because you looked at the orders corresponding to your customer via a different query the customer&#039;s order collection was populated. This is a surprising side-effect to say the least. Fortunately, I believe it is possible to set the merge options for the query so you can turn this off.</description>
		<content:encoded><![CDATA[<p>The strange thing that is happening with EF is not the lack of lazy loading, its that the data showed up magically after you queried for all orders. The reason it showed no orders to begin with was because there is no implicit lazy loading, so the collection is empty until you explicity call load. Then when you queried it again, after looking at all orders, suddenly there were orders loaded; the collection changed on its own. This happens because EF allows merge behaviors ala DataSet when queries are run. Any entities that are retrieved are put into the cache and if related entities are found also in the cache they are wired together. So, simply because you looked at the orders corresponding to your customer via a different query the customer&#8217;s order collection was populated. This is a surprising side-effect to say the least. Fortunately, I believe it is possible to set the merge options for the query so you can turn this off.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: blackberry sql server name &#124; Digg hot tags</title>
		<link>http://www.hackification.com/2008/12/03/linq-to-entities-the-blackberry-storm-of-orms/comment-page-1/#comment-247</link>
		<dc:creator>blackberry sql server name &#124; Digg hot tags</dc:creator>
		<pubDate>Thu, 04 Dec 2008 06:31:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.hackification.com/?p=60#comment-247</guid>
		<description>[...] Vote  LINQ-to-Entities: The Blackberry Storm of ORMs? [...]</description>
		<content:encoded><![CDATA[<p>[...] Vote  LINQ-to-Entities: The Blackberry Storm of ORMs? [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: microsoft sql server name blackberry &#124; Digg hot tags</title>
		<link>http://www.hackification.com/2008/12/03/linq-to-entities-the-blackberry-storm-of-orms/comment-page-1/#comment-241</link>
		<dc:creator>microsoft sql server name blackberry &#124; Digg hot tags</dc:creator>
		<pubDate>Thu, 04 Dec 2008 01:27:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.hackification.com/?p=60#comment-241</guid>
		<description>[...] Vote  LINQ-to-Entities: The Blackberry Storm of ORMs? [...]</description>
		<content:encoded><![CDATA[<p>[...] Vote  LINQ-to-Entities: The Blackberry Storm of ORMs? [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
