<?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: Hacking LINQ Expressions: Select With Index</title>
	<atom:link href="http://lostechies.com/keithdahlby/2009/09/15/hacking-linq-expressions-select-with-index/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/keithdahlby/2009/09/15/hacking-linq-expressions-select-with-index/</link>
	<description>Git, .NET and more</description>
	<lastBuildDate>Wed, 12 Jun 2013 13:14:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: Chris Missal</title>
		<link>http://lostechies.com/keithdahlby/2009/09/15/hacking-linq-expressions-select-with-index/#comment-10</link>
		<dc:creator>Chris Missal</dc:creator>
		<pubDate>Tue, 15 Sep 2009 22:14:22 +0000</pubDate>
		<guid isPermaLink="false">/blogs/dahlbyk/archive/2009/09/15/hacking-linq-expressions-select-with-index.aspx#comment-10</guid>
		<description>This made a lot more sense after I saw you code it. :)</description>
		<content:encoded><![CDATA[<p>This made a lot more sense after I saw you code it. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keith Dahlby</title>
		<link>http://lostechies.com/keithdahlby/2009/09/15/hacking-linq-expressions-select-with-index/#comment-9</link>
		<dc:creator>Keith Dahlby</dc:creator>
		<pubDate>Tue, 15 Sep 2009 13:26:26 +0000</pubDate>
		<guid isPermaLink="false">/blogs/dahlbyk/archive/2009/09/15/hacking-linq-expressions-select-with-index.aspx#comment-9</guid>
		<description>You certainly could inline the Select call within a query, however you&#039;re then stuck using an anonymous type and an &quot;extra&quot; variable. You either end up with variables like x with properties like y that mean nothing, or code that looks like this:

from ProductWithIndex in Products.Select((p,i) =&gt; new { Product = p, Index = i })
where ProductWithIndex.Product.IsSpecial()
select new { ProductWithIndex.Index, ProductWithIndex.Product.ID };

By leaning on the query expression, that intermediate identifier (x or ProductWithIndex) becomes transparent. So in the body of the Join we have access to x, y and i without having to mess with any secondary types and unintuitive x.y syntax.

At that point the query vs. method translation comes down to the same question as always: is the query inflexibility made up for by the value of clean expression of intent?</description>
		<content:encoded><![CDATA[<p>You certainly could inline the Select call within a query, however you&#8217;re then stuck using an anonymous type and an &#8220;extra&#8221; variable. You either end up with variables like x with properties like y that mean nothing, or code that looks like this:</p>
<p>from ProductWithIndex in Products.Select((p,i) => new { Product = p, Index = i })<br />
where ProductWithIndex.Product.IsSpecial()<br />
select new { ProductWithIndex.Index, ProductWithIndex.Product.ID };</p>
<p>By leaning on the query expression, that intermediate identifier (x or ProductWithIndex) becomes transparent. So in the body of the Join we have access to x, y and i without having to mess with any secondary types and unintuitive x.y syntax.</p>
<p>At that point the query vs. method translation comes down to the same question as always: is the query inflexibility made up for by the value of clean expression of intent?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephen</title>
		<link>http://lostechies.com/keithdahlby/2009/09/15/hacking-linq-expressions-select-with-index/#comment-8</link>
		<dc:creator>Stephen</dc:creator>
		<pubDate>Tue, 15 Sep 2009 09:59:21 +0000</pubDate>
		<guid isPermaLink="false">/blogs/dahlbyk/archive/2009/09/15/hacking-linq-expressions-select-with-index.aspx#comment-8</guid>
		<description>As you say, its a hack- ultimately I&#039;m not sure the linq syntax is always that great, and I often just write the extension methods directly instead.. I would think you could just have done:

from x in seq.Select((y, i) =&gt; new { y, i })

or write an extension method:

from x in seq.WithIndexes()</description>
		<content:encoded><![CDATA[<p>As you say, its a hack- ultimately I&#8217;m not sure the linq syntax is always that great, and I often just write the extension methods directly instead.. I would think you could just have done:</p>
<p>from x in seq.Select((y, i) => new { y, i })</p>
<p>or write an extension method:</p>
<p>from x in seq.WithIndexes()</p>
]]></content:encoded>
	</item>
</channel>
</rss>
