<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx</link><description>This post covers one of the most important and frequently misunderstood LINQ features. Understanding deferred execution is a rite of passage that LINQ developers must undergo before they can hope to harness the full power of this technology. The contents</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#6720305</link><pubDate>Mon, 10 Dec 2007 09:51:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6720305</guid><dc:creator>DotNetKicks.com</dc:creator><description>&lt;p&gt;You've been kicked (a good thing) - Trackback from DotNetKicks.com&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#6753235</link><pubDate>Thu, 13 Dec 2007 03:36:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6753235</guid><dc:creator>Jeff LeBert</dc:creator><description>&lt;p&gt;I think your example is a little misleading. In the last code example you have:&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;var query = (...).Count();&lt;/p&gt;
&lt;p&gt;The Count method returns an integer not a query. Therefore naming your variable &amp;quot;query&amp;quot; is the confusing part. It would have been better to do the following:&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;int count = (...).Count();&lt;/p&gt;
&lt;p&gt;In this way it is obvious the count is only done once.&lt;/p&gt;
</description></item><item><title>LINQ and Deferred Execution Video</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#6768338</link><pubDate>Fri, 14 Dec 2007 10:16:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6768338</guid><dc:creator>Charlie Calvert's Community Blog</dc:creator><description>&lt;p&gt;Here is a video version of the Deferred Execution post I published on December 9. You can watch the video&lt;/p&gt;
</description></item><item><title>LINQ and Deferred Execution Video</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#6768501</link><pubDate>Fri, 14 Dec 2007 10:54:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6768501</guid><dc:creator>Noticias externas</dc:creator><description>&lt;p&gt;Here is a video version of the Deferred Execution post I published on December 9. You can watch the video&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#6782745</link><pubDate>Sun, 16 Dec 2007 15:48:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6782745</guid><dc:creator>Steve</dc:creator><description>&lt;p&gt;So, if I first do a .ToList() before enumerating, then it will make one db call?&lt;/p&gt;
&lt;p&gt;if I loop through as in your above sample of a foreach - does it make a call for each one - or just on the first loop?&lt;/p&gt;
&lt;p&gt;Please clarify&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#6820858</link><pubDate>Fri, 21 Dec 2007 00:39:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6820858</guid><dc:creator>manit</dc:creator><description>&lt;p&gt;great article, i just ran into a problem with this today. Is there a way to avoid Deferred Execution?&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#6821208</link><pubDate>Fri, 21 Dec 2007 01:23:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6821208</guid><dc:creator>Matt Brown</dc:creator><description>&lt;p&gt;Very well written article with clear examples. Thanks!&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#6847136</link><pubDate>Sun, 23 Dec 2007 21:24:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6847136</guid><dc:creator>nightwatch77</dc:creator><description>&lt;p&gt;Hey, in third example (SimpleQuery03) you are using variable reference in query expression (the 'city' variable). &lt;/p&gt;
&lt;p&gt;Please tell me how LINQ updates the filter condition in query if you modify the value of 'city' AFTER creating the query? In my opinion this shouldn't work, as strings are immutable.&lt;/p&gt;
&lt;p&gt;Saying it shorter: the query expression has no way of seeing if 'city' variable has changed, as the variable is not in the scope of query.&lt;/p&gt;
&lt;p&gt;Or are there some 'closures' in C#? How does it work?&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#6874711</link><pubDate>Thu, 27 Dec 2007 07:33:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6874711</guid><dc:creator>onevextchuck</dc:creator><description>&lt;p&gt;Nightwatch: It's just that age old issue of base types vs reference types. &amp;nbsp;Strings may be immutable, but they are stored on the heap which means that they are reference types. &amp;nbsp;If the LINQ query is not creating a local copy of the value, it will use whatever is held in that reference when it gets around to executing the query.&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#6879948</link><pubDate>Thu, 27 Dec 2007 23:59:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6879948</guid><dc:creator>Dennis van der Stelt</dc:creator><description>&lt;p&gt;@Jef : I think the example is excellent, because this is something people will actually write, without knowing what they're actually doing!&lt;/p&gt;
</description></item><item><title>LINQ to SQL vs. DBA's</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#6880372</link><pubDate>Fri, 28 Dec 2007 01:57:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6880372</guid><dc:creator>Dennis van der Stelt</dc:creator><description>&lt;p&gt;Why is it that in Oracle world, it&amp;amp;#39;s much more custom to have a database administrator (DBA) on your&lt;/p&gt;
</description></item><item><title>LINQ and Deferred Execution Video</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#6880642</link><pubDate>Fri, 28 Dec 2007 03:38:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6880642</guid><dc:creator>{ The Smoking Code }</dc:creator><description>&lt;p&gt;LINQ and Deferred Execution Video&lt;/p&gt;
</description></item><item><title>LINQ and Deferred Execution Video</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#6880732</link><pubDate>Fri, 28 Dec 2007 03:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6880732</guid><dc:creator>Mighell's Mobile Blog</dc:creator><description>&lt;p&gt;Charlie ha postato un interessante video che spiega in un modo semplice ed oserei dire disarmante, il&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#6886414</link><pubDate>Fri, 28 Dec 2007 19:25:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6886414</guid><dc:creator>Zloth</dc:creator><description>&lt;p&gt;It's the variable changing that's more interesting to me. &amp;nbsp;If you do something like (switching to VB here):&lt;/p&gt;
&lt;p&gt;Dim sTemp as string = FormatPhoneForDB(&amp;quot;9139130000&amp;quot;)&lt;/p&gt;
&lt;p&gt;Dim Q1 = from x in db.Table where x.Phone=sTemp&lt;/p&gt;
&lt;p&gt;sTemp = FormatPhoneForDB(&amp;quot;3193190000&amp;quot;)&lt;/p&gt;
&lt;p&gt;Dim Q2 = from y in db.Table where y.Phone=sTemp&lt;/p&gt;
&lt;p&gt;DataGridView1.DataSource = Q1&lt;/p&gt;
&lt;p&gt;DataGridView2.DataSource = Q2&lt;/p&gt;
&lt;p&gt;Both data grids are going to show the data for the second phone number! &amp;nbsp;On the other hand, if you don't use an sTemp variable and just put the call to the FormatPhoneForDB function right in the query, I do get the two different datasets. &amp;nbsp;Yow. &amp;nbsp;Nasty. &amp;nbsp;I think we're going to be seeing a lot of subtle bugs on this one.&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#6951447</link><pubDate>Wed, 02 Jan 2008 12:45:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6951447</guid><dc:creator>Ashwani</dc:creator><description>&lt;p&gt;1. How to extract data from the tables using mannual connectivity to database with LINQ.&lt;/p&gt;
&lt;p&gt;2. How to use Stored procedures with LINQ.&lt;/p&gt;
&lt;p&gt;3. How to Select multiple values through Select statement with LINQ.&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#6957893</link><pubDate>Wed, 02 Jan 2008 21:57:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6957893</guid><dc:creator>Thanda</dc:creator><description>&lt;p&gt;Is Microsoft recommending developers to embed SQL code in the form of LINQ into C# code? From a maintenance standpoint, isn't it better to keep your SQL code in stored procedures?&lt;/p&gt;
&lt;p&gt;PS: Ignore if you think this is off-topic.&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#6958986</link><pubDate>Wed, 02 Jan 2008 23:36:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6958986</guid><dc:creator>Viper</dc:creator><description>&lt;p&gt;So, you're saying that the expression tree stores the address of the string variable (a pointer to a pointer to a string on the heap) as opposed to the value of it (a pointer to a string on the heap). &amp;nbsp;If that's true, then what if you write a function that returns a query but the string used in it is a local variable (and, thus, on the stack)? &amp;nbsp;Sound like a runtime error (or at least an evil bug) would result when the query is exectued (and the stack frame no longer exists).&lt;/p&gt;
&lt;p&gt;I can't imgaine why the expression tree generator would copy references to the variables used to compose it as opposed to their current values.&lt;/p&gt;
&lt;p&gt;Maybe I've misread this post but something doesn't seem to add up here.&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#6960212</link><pubDate>Thu, 03 Jan 2008 01:32:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6960212</guid><dc:creator>Wayne</dc:creator><description>&lt;p&gt;I have yet to involve myself with LINQ yet, but I was just thinking how I've been saying that query work should be left for stored procs. &amp;nbsp;This is yet another avenue that fly-by-nighters and hacks will use to muddle up the code that I will have to take over and support.&lt;/p&gt;
&lt;p&gt;So much for leaving SQL in the database, now it's going back into the code, where I believe it shouldn't be (for larger projects mind you...)&lt;/p&gt;
&lt;p&gt;Great article tho..had to bitch a little.&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#6973872</link><pubDate>Fri, 04 Jan 2008 04:26:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6973872</guid><dc:creator>Matt Neerincx (MSFT)</dc:creator><description>&lt;p&gt;I just wonder to myself how I am going to debug this crazy stuff. &amp;nbsp;I can just see a storm cloud coming when we people start doing some serious LINQ stuff and it does not work as expected.&lt;/p&gt;
&lt;p&gt;Howabout some debugging examples, show us what is happening for real under the covers?&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#6980910</link><pubDate>Fri, 04 Jan 2008 19:40:03 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6980910</guid><dc:creator>David Preeves</dc:creator><description>&lt;p&gt;Since it is straightfoward to create a function to query data from a database via a stored proc or query what is the main advantage to using linq? I can see that it would be advantageous for lists, queues, etc. but for database queries I'm at a loss to why one would use this technology. Isn't querying a stored procedure more efficient than building queries on the fly on the client? Also, isn't it kind of messy to throw around ad hoc queries in code all over the place inside the program? What if a table name of field changes?&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#7015721</link><pubDate>Mon, 07 Jan 2008 17:30:03 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7015721</guid><dc:creator>Alan Cummings</dc:creator><description>&lt;p&gt;Good article that highlights deferred execution, however, it does introduce a level of confusion by the use of implicit typing with var (as pointed out by Jeff LeBert). The use of explicit typing (ie: int, IQueryable&amp;lt;Customer&amp;gt;, and so on) would have removed the ambiguity - but it does serve to highlight the dangers of overusing implicit typing.&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#7031419</link><pubDate>Tue, 08 Jan 2008 22:03:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7031419</guid><dc:creator>Jim Huddle</dc:creator><description>&lt;p&gt;You have shown us an extremely likely bug.&lt;/p&gt;
&lt;p&gt;Is there any productive work that could be done AFTER assigning the (SQL-like) LINQ query to the &amp;quot;var&amp;quot;, but before the query hits the back end? &amp;nbsp;If the answer is 'no', then this is nothing more than a bug, waiting to be fixed.&lt;/p&gt;
&lt;p&gt;Thanks for the heads-up.&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#7065512</link><pubDate>Fri, 11 Jan 2008 04:48:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7065512</guid><dc:creator>Zbyszek</dc:creator><description>&lt;p&gt;@David - I think that main thing missed from all explanations is that LINQ changes completely the way you see access to the database. Just think about your objects as not being in the database, but placed in the memory (kind of like if you have moved whoe database to the collections of objects in the memory at the beginning of the program). DataContext keeps data in the cache and you are supposed to trust DLINQ engine to translate everything to the queries when neccessary. So in fact all your code works on objects in the memory.&lt;/p&gt;
&lt;p&gt;As for your question re stored procedures, I am still using dlinq for them, as I have strongly typed result and much more elegant code. &lt;/p&gt;
&lt;p&gt;If you change types in your tables or add columns or modify types in the result of the stored procedure you would have to recreate dbml file.&lt;/p&gt;
&lt;p&gt;If you have doubts - do not worry, you are not the only one :) But I think this is a step in a new direction, something which may change the way we think about coding and database access.&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#7092747</link><pubDate>Sun, 13 Jan 2008 03:15:26 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7092747</guid><dc:creator>some one</dc:creator><description>&lt;p&gt;I'm now able to convert an application written in a 4GL language from 1995 to .NET 3.5 with LINQ. Those languages are heavy wih in line SQL statements which are easier to convert to LINQ than some other means with just .NET 2.0. &lt;/p&gt;
&lt;p&gt;Just because it is there does not mean you have to use it. One could also put in place guidelines on how to use so as to not use in a way you don't see fit. And if you are sick of picking up other peoples code then don't. Otherwise I have some old 4GL code if you would like to convert over to LINQ.&lt;/p&gt;
&lt;p&gt;Thank you for the article this helps explain to others what is going on.&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#7187281</link><pubDate>Mon, 21 Jan 2008 22:29:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7187281</guid><dc:creator>Sir Taniel</dc:creator><description>&lt;p&gt;As soon as I saw LINQ to SQL I thought WOW isn't this great. Most of my development time is creating stored procs and class objects for each of my tables. I was able to create a one-to-many relationship and create a grid that allowed for insert/updates/deletes without writing any code. Cool right? I think not...&lt;/p&gt;
&lt;p&gt;After seeing more and more of LINQ I am doubtful of ever using this in a production environment. Hence the articles nature in general. Also someone else mentioned having to pickup someone elsess buggy LINQ queries. I quiver to thought of the phone call i will get to fix an application that was shipped off-shores to be built to save cost and LINQ was used.&lt;/p&gt;
&lt;p&gt;Also I wondered when using LINQ to SQL if I modify a database does the code need re-compiled and re-deployed to each client in a non-web non-remoted environment?&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#7219710</link><pubDate>Thu, 24 Jan 2008 13:29:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7219710</guid><dc:creator>Holger Flick</dc:creator><description>&lt;p&gt;This post shows how important it is to type variables properly if one can instead of using &amp;quot;var&amp;quot;. If you typed properly in your last &amp;quot;query&amp;quot;, you'd be more aware of the fact that query actually is an integer that is not going to change by writing it to the console multiple times.&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#7476485</link><pubDate>Wed, 06 Feb 2008 00:46:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7476485</guid><dc:creator>Niranjan Limaye</dc:creator><description>&lt;p&gt;I am not a techno geek, I am just another programmer in the big ocean of information technology. Also do not have much exposure to LINQ. I still remember my repartee with another Java Architect (colleague), he said &amp;quot;Working with Microsoft is like getting married after every 2 years.&amp;quot;. wait wait wait, I don't want to start Java vs. .NET comparison here. I apologies, If you find my comments little bold or adventures.&lt;/p&gt;
&lt;p&gt;This looks like another &amp;quot;programming adventure&amp;quot; to do things in some other exicting..!!! way.&lt;/p&gt;
&lt;p&gt;I don't see any business benefits of using this when DB native stored procedures / stored objects can achieve the same result in safer, faster, quicker way. Microsoft is contradicting it's own promotion on benefits of Stored procedures, stored functions or DB native objects.&lt;/p&gt;
&lt;p&gt;They can really come up with true DB independent data access layer and it would be lot better for middle-tier programmers and multi-database applications or systems.&lt;/p&gt;
&lt;p&gt;1. Allow middle-tier programmers to write consistent SQL. This includes stored procedure calls or SQL query calls or any other DB execution call, may XML queries etc.&lt;/p&gt;
&lt;p&gt;2. Microsoft Query Engine should analyze the SQL and convert the same into native database semantics on which said query will be executed, it can be Oracle, SQL Server, or any open source database or object oriented database. To achieve this, Microsoft can follow their own data provider pattern. Where Oracle will provide its query engine, SQL Server will provide its own etc.&lt;/p&gt;
&lt;p&gt;3. Pass the 'parsed' SQL to native database execute the same on the underlying database and return the result back to the middle-tier in 'typed dataset' format. Embed your data-adapters. Middle - tier or business process layer will make single API call or business call to retrieve the data.&lt;/p&gt;
&lt;p&gt;This way .NET middle tier programmers does not need to understand underlying database and able to write DB independent SQL in their Data Access Layers.&lt;/p&gt;
&lt;p&gt;This would be true DB independent data access layer and benefit programmers in many way.&lt;/p&gt;
</description></item><item><title>DOWNLOAD LINKS: Public Sector Developer Conference (LA / San Diego)</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#7550186</link><pubDate>Sat, 09 Feb 2008 05:07:49 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7550186</guid><dc:creator>Gold Coast</dc:creator><description>&lt;p&gt;Thanks to everyone who attended! As promised, I have gathered all the decks and code. Here are the links:&lt;/p&gt;
</description></item><item><title>DOWNLOAD LINKS: Public Sector Developer Conference (LA / San Diego)</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#7550231</link><pubDate>Sat, 09 Feb 2008 05:08:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7550231</guid><dc:creator>Public Sector Developer Weblog</dc:creator><description>&lt;p&gt;Thanks to everyone who attended!&amp;amp;#160; As promised, I have gathered all the decks and code.&amp;amp;#160; Here&lt;/p&gt;
</description></item><item><title>DOWNLOAD LINKS: Public Sector Developer Conference (LA / San Diego)</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#7550565</link><pubDate>Sat, 09 Feb 2008 05:24:59 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7550565</guid><dc:creator>Noticias externas</dc:creator><description>&lt;p&gt;Thanks to everyone who attended!&amp;amp;#160; As promised, I have gathered all the decks and code.&amp;amp;#160; Here&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#7621387</link><pubDate>Tue, 12 Feb 2008 00:35:26 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7621387</guid><dc:creator>Dale</dc:creator><description>&lt;p&gt;LINQ is just a bad idea all around. &amp;nbsp;This leaves Microsoft as the database code optimizer for every database rather than letting developers and trained, experienced DBAs optimizing query code. &amp;nbsp;Just as generic code generators develop bad code, generic database access develops poor performing database access.&lt;/p&gt;
&lt;p&gt;This makes about as much sense as merging the two worst Internet search engines in the world with the expectation that between them they can beat the best search engine.&lt;/p&gt;
&lt;p&gt;I think bad design added to bad design yields logarithmically worse design rather than adding up to good design.&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#7692700</link><pubDate>Thu, 14 Feb 2008 16:39:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7692700</guid><dc:creator>Dev</dc:creator><description>&lt;p&gt;Not at all a bad idea. It is nothing to do with the database at all. At the client side if you want to extract subset of the data from the extracted DataSet LINQ comes into rescue. &lt;/p&gt;
&lt;p&gt;For eg: &lt;/p&gt;
&lt;p&gt;foreach (Row in DataSet.Table.Rows)&lt;/p&gt;
&lt;p&gt;...............&lt;/p&gt;
&lt;p&gt;............. YourListBox.Items.Add........&lt;/p&gt;
&lt;p&gt;I think LINQ syntax is better ...returns a list&lt;/p&gt;
&lt;p&gt;It is not that every query you need to use deffered execution. It is just a value addition you can also use deffered execution if you want. Otherwise just use LINQ to query your DataSet returned.&lt;/p&gt;
&lt;p&gt;Hope this answers most of the comments about LINQ I guess.&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#7693275</link><pubDate>Thu, 14 Feb 2008 17:07:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7693275</guid><dc:creator>Dev</dc:creator><description>&lt;p&gt;Does not execute the query on the database it executes the query on the DataSet.&lt;/p&gt;
&lt;p&gt;For eg 2:&lt;/p&gt;
&lt;p&gt;XElement xmlCustomers = new XElement(&amp;quot;customers&amp;quot;,&lt;/p&gt;
&lt;p&gt;from c in customers&lt;/p&gt;
&lt;p&gt;where c.Country == Countries.India&lt;/p&gt;
&lt;p&gt;select new XElement(&amp;quot;customer&amp;quot;,&lt;/p&gt;
&lt;p&gt;new XElement(&amp;quot;name&amp;quot;,c.Name),&lt;/p&gt;
&lt;p&gt;new XElement(&amp;quot;city&amp;quot;,c.City),&lt;/p&gt;
&lt;p&gt;new XElement(&amp;quot;country&amp;quot;,c.COuntry)));&lt;/p&gt;
&lt;p&gt;to create from a db.customers or use &lt;/p&gt;
&lt;p&gt;XElement xmlCustomers = XElement.Load(@&amp;quot;..\..\customer.xml&amp;quot;);&lt;/p&gt;
&lt;p&gt;from an xml file or from an xml string&lt;/p&gt;
&lt;p&gt;now I can query &lt;/p&gt;
&lt;p&gt;var cities= xmlCustomers.DescendantsAndSelf(&amp;quot;city&amp;quot;); // city is a node&lt;/p&gt;
&lt;p&gt;How difficult it was to iterate through XmlNodeList extract each element even though we used XPath to qry the subset.&lt;/p&gt;
&lt;p&gt;Now..with LINQ&lt;/p&gt;
&lt;p&gt;foreach(var city in cities) {&lt;/p&gt;
&lt;p&gt;Console.WriteLine(city);&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#7718433</link><pubDate>Fri, 15 Feb 2008 19:48:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7718433</guid><dc:creator>Diane Wilson</dc:creator><description>&lt;p&gt;Having spent a few months immersed in LINQ, I feel compelled to comment on a few things here.&lt;/p&gt;
&lt;p&gt;First, stored procedures are not &amp;quot;safe&amp;quot; and &amp;quot;easy&amp;quot; except from the DBA's perspective. From an application perspective (using ADO.NET), you have no design-time or compile-time support at all. Sproc names are strings, parameter names are strings, column names in the result set are strings, and type information on both parameters and results are set and used without any real compile-time verification. &lt;/p&gt;
&lt;p&gt;Further, if the sproc changes, it's like any other schema change, and you have no real tools to track down where all the calls to the sproc are, so they can be fixed. You have only regression testing (and hope it catches them all), or your help desk after code goes to production.&lt;/p&gt;
&lt;p&gt;LINQ fixes all that. It has complete type-checking and compile-time support for all sproc names, parameter names, and result names. Even if the only thing you use LINQ for is calling your stored procedures, it's a huge improvement over ADO.NET.&lt;/p&gt;
&lt;p&gt;Second, the issue of schema changes. Find SQLMetal. (Hint: it's in the Microsoft SDK that comes with VS2008.) Learn to use it to generate your schema mapping for LINQ. Put it in your daily build. It will pick up schema changes, as well as changes to sprocs, views, and functions. Use SQLMetal output as your DataContext for all LINQ queries. If the schema changes affect ANY of your LINQ queries, the compiler will find them and tell you about them. Isn't that better than waiting for things to blow up down the road?&lt;/p&gt;
&lt;p&gt;As far as deferred execution goes, yes, it's a change, but you just have to learn how LINQ works before it will work well for you. In that sense, it's no different from learning any other powerful and complex new technology. The advantages that LINQ offers in terms of flexibility, productivity, and reliability will follow only after you understand LINQ's approach to generating SQL, and that includes deferred execution.&lt;/p&gt;
&lt;p&gt;There are plus sides to deferred execution. You can define a basic query, then extend it:&lt;/p&gt;
&lt;p&gt;IQueryable&amp;lt;Category&amp;gt; myQuery = from cat in NW.Categories select cat;&lt;/p&gt;
&lt;p&gt;Category oneCat = myQuery.Where(c =&amp;gt; c.ID == 1).SingleOrDefault();&lt;/p&gt;
&lt;p&gt;One poster above mentioned that it's better to use explicit typing on LINQ queries, and that is generally true. &amp;quot;var&amp;quot; becomes totally safe only when you know what you're getting, but it also provides a learning-level entry point, and it does work just fine for local variable access, once you know the rules.&lt;/p&gt;
&lt;p&gt;As for the question of referring to local variables, the real &amp;quot;best practice&amp;quot; here is precompiled queries; they provide both a safe way to use local data in a LINQ query, and they provide greatly improved performance for queries that are going to be re-used with any frequency.&lt;/p&gt;
&lt;p&gt;Here's an example of a compiled query:&lt;/p&gt;
&lt;p&gt;private static Func&amp;lt;Northwind, string, IQueryable&amp;lt;NW.Data.Customer&amp;gt;&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CustomerByIDQuery =&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CompiledQuery.Compile((Northwind ndc, string custID) &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;=&amp;gt; from c in ndc.Customers &amp;nbsp; &amp;nbsp; where c.CustomerID == custID select c);&lt;/p&gt;
&lt;p&gt;Calling a compiled query is easy, and passes local data as a parameter to the query:&lt;/p&gt;
&lt;p&gt;NW.Data.Customer _customer = CustomerByIDQuery(m_DC, _custID).SingleOrDefault();&lt;/p&gt;
&lt;p&gt;Anyway, enough time on my soap-box, but I just wanted to throw in my experience with LINQ. I think it's one of the finest pieces of software engineering I've seen in a while, but you really do have to dig in to understand it and use it well.&lt;/p&gt;
&lt;p&gt;BTW, there's an excellent book out now by Joseph C. Rattz: pro LINQ with Visual Studio C# 2008. It's an APress book, and it's a great book for both learning and reference.&lt;/p&gt;
</description></item><item><title>给热爱学习的同学们推荐一些顶级的c# Blogs链接</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#7797118</link><pubDate>Tue, 19 Feb 2008 19:50:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7797118</guid><dc:creator>无常</dc:creator><description>&lt;p&gt;在TI行业，中文的资料永远都比英文的慢几个月，而且原创性的文章也少得可怜，有空时，不妨去这些英文技术BLOG溜达溜达，也许会有意外的惊喜。&lt;/p&gt;
</description></item><item><title>给热爱学习的同学们推荐一些顶级的c# Blogs链接</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#7798234</link><pubDate>Tue, 19 Feb 2008 20:45:03 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7798234</guid><dc:creator>cnblogs.com</dc:creator><description>&lt;p&gt;在IT行业，中文的资料永远都比英文的慢几个月，而且原创性的也少得可怜，有空时，不妨去这些英文技术BLOG溜达溜达，也许会有意外的惊喜。 好的C#博客应该符合这些条件： 有用的新闻、信息、技巧和代码例子&lt;/p&gt;
</description></item><item><title>Getting Started With LINQ To SQL</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#7819866</link><pubDate>Wed, 20 Feb 2008 19:03:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7819866</guid><dc:creator>Hilton Giesenow's Jumbled Mind</dc:creator><description>&lt;p&gt;Considering I&amp;amp;#39;ve put a few posts up about LINQ To SQL, I realised I&amp;amp;#39;ve never shared some of the&lt;/p&gt;
</description></item><item><title>Getting Started With LINQ To SQL(转)</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#8350082</link><pubDate>Wed, 02 Apr 2008 09:48:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8350082</guid><dc:creator>王德水</dc:creator><description>&lt;p&gt;原文地址:&lt;a rel="nofollow" target="_new" href="http://dotnet.org.za/hiltong/archive/2008/02/20/getting-started-with-linq-to-sql.aspxConsideri"&gt;http://dotnet.org.za/hiltong/archive/2008/02/20/getting-started-with-linq-to-sql.aspxConsideri&lt;/a&gt;...&lt;/p&gt;
</description></item><item><title>LINQ To SQL : Dynamically Adding a Shared OrderBy Clause</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#8494652</link><pubDate>Mon, 12 May 2008 18:13:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8494652</guid><dc:creator>Hilton Giesenow's Jumbled Mind</dc:creator><description>&lt;p&gt;One of the features of LINQ queries is Deferred Execution, which Charlie Calvert discusses here with&lt;/p&gt;
</description></item><item><title>Dynamic Construction of a LINQ Expression</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#8528338</link><pubDate>Wed, 21 May 2008 18:05:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8528338</guid><dc:creator>Jonas Stawski's Blog</dc:creator><description>&lt;p&gt;One of the great things about LINQ is it's deferred execution. Read about deferred execution here and&lt;/p&gt;
</description></item><item><title>Dynamic Construction of a LINQ Expression</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#8625920</link><pubDate>Fri, 20 Jun 2008 20:21:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8625920</guid><dc:creator>Jonas Stawski</dc:creator><description>&lt;p&gt;Dynamic Construction of a LINQ Expression&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#8652413</link><pubDate>Wed, 25 Jun 2008 18:59:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8652413</guid><dc:creator>sdoc</dc:creator><description>&lt;p&gt;awesome article!! after spending half of my day not realizing my problem was related to deferred execution....i think this article is def LINQ 101&lt;/p&gt;
</description></item><item><title>给热爱学习的同学们推荐一些顶级的c# Blogs链接 </title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#8921739</link><pubDate>Wed, 03 Sep 2008 12:38:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8921739</guid><dc:creator>布衣</dc:creator><description>&lt;p&gt;在IT行业，中文的资料永远都比英文的慢几个月，而且原创性的也少得可怜，有空时，不妨去这些英文技术BLOG溜达溜达，也许会有意外的惊喜。 好的C#博客应该符合这些条件： 有用的新闻、信息、技巧和代码例子 定期更新 原创内容，不是广告文章盗用别人的文章 良好的组织，包含分类和tags 健康的讨论和读者评论 有一定的个人见解，最好还有点幽默感，但又不是自己在嗐吹牛&lt;/p&gt;
</description></item><item><title>Deferred Execution trong LINQ</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#9691864</link><pubDate>Wed, 03 Jun 2009 20:03:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9691864</guid><dc:creator>Bao Duy's Blog</dc:creator><description>&lt;p&gt;&amp;amp;#160; Trong LINQ, c&amp;#243; một cơ chế gi&amp;#250;p tối ưu h&amp;#243;a việc truy xuất dữ liệu đ&amp;#243; l&amp;#224; cơ chế Deferred Execution&lt;/p&gt;
</description></item><item><title>re: LINQ and Deferred Execution</title><link>http://blogs.msdn.com/charlie/archive/2007/12/09/deferred-execution.aspx#9822216</link><pubDate>Tue, 07 Jul 2009 13:46:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9822216</guid><dc:creator>Nisha</dc:creator><description>&lt;p&gt;great article..thanks for this article..&lt;/p&gt;
</description></item></channel></rss>