<?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: IQueryable&#60;T&#62; vs. IEnumerable&#60;T&#62; in LINQ to SQL queries</title>
	<atom:link href="http://jonkruger.com/blog/2007/10/19/iqueryable-vs-ienumerable-in-linq-to-sql-queries/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonkruger.com/blog/2007/10/19/iqueryable-vs-ienumerable-in-linq-to-sql-queries/</link>
	<description></description>
	<pubDate>Fri, 18 May 2012 00:53:56 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Hamish Graham</title>
		<link>http://jonkruger.com/blog/2007/10/19/iqueryable-vs-ienumerable-in-linq-to-sql-queries/comment-page-1/#comment-6025</link>
		<dc:creator>Hamish Graham</dc:creator>
		<pubDate>Tue, 27 Mar 2012 11:38:19 +0000</pubDate>
		<guid isPermaLink="false">http://jonkruger.com/blog/2007/10/19/iqueryable-vs-ienumerable-in-linq-to-sql-queries/#comment-6025</guid>
		<description>Hi Jon, good stuff!

I fleshed out your examples in a blog post here: http://hamishgraham.net/post/RE-IQueryable-vs-IEnumerable-in-LINQ-to-SQL-queries.aspx</description>
		<content:encoded><![CDATA[<p>Hi Jon, good stuff!</p>
<p>I fleshed out your examples in a blog post here: <a href="http://hamishgraham.net/post/RE-IQueryable-vs-IEnumerable-in-LINQ-to-SQL-queries.aspx" rel="nofollow">http://hamishgraham.net/post/RE-IQueryable-vs-IEnumerable-in-LINQ-to-SQL-queries.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cherukuri Venkateswarlu</title>
		<link>http://jonkruger.com/blog/2007/10/19/iqueryable-vs-ienumerable-in-linq-to-sql-queries/comment-page-1/#comment-4678</link>
		<dc:creator>Cherukuri Venkateswarlu</dc:creator>
		<pubDate>Fri, 18 Sep 2009 07:16:45 +0000</pubDate>
		<guid isPermaLink="false">http://jonkruger.com/blog/2007/10/19/iqueryable-vs-ienumerable-in-linq-to-sql-queries/#comment-4678</guid>
		<description>Good article. It helped me alot.</description>
		<content:encoded><![CDATA[<p>Good article. It helped me alot.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: IQueryable vs IEnumerable &#171; Ramani Sandeep</title>
		<link>http://jonkruger.com/blog/2007/10/19/iqueryable-vs-ienumerable-in-linq-to-sql-queries/comment-page-1/#comment-4670</link>
		<dc:creator>IQueryable vs IEnumerable &#171; Ramani Sandeep</dc:creator>
		<pubDate>Tue, 08 Sep 2009 05:45:45 +0000</pubDate>
		<guid isPermaLink="false">http://jonkruger.com/blog/2007/10/19/iqueryable-vs-ienumerable-in-linq-to-sql-queries/#comment-4670</guid>
		<description>[...] IQueryable&#60;T&#62; vs. IEnumerable&#60;T&#62; in LINQ to SQL queries by Jon Kruger [...]</description>
		<content:encoded><![CDATA[<p>[...] IQueryable&lt;T&gt; vs. IEnumerable&lt;T&gt; in LINQ to SQL queries by Jon Kruger [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Kruger</title>
		<link>http://jonkruger.com/blog/2007/10/19/iqueryable-vs-ienumerable-in-linq-to-sql-queries/comment-page-1/#comment-3840</link>
		<dc:creator>Jon Kruger</dc:creator>
		<pubDate>Wed, 24 Jun 2009 18:49:18 +0000</pubDate>
		<guid isPermaLink="false">http://jonkruger.com/blog/2007/10/19/iqueryable-vs-ienumerable-in-linq-to-sql-queries/#comment-3840</guid>
		<description>@Venkat,

Try this then...

@Venkat,

Try changing it to this:

var query = (from o in this.DBContext.mvc_getSelectGrids_ForProgramCode(paramProgramCode, start, limit, ref total)
select new
{
o.RgID,
o.GridLayoutLocation,
o.ObjectType,
o.Label,
o.AttribCodes
});

var list = query.ToList();
list = query.Skip(start).Take(limit).ToList();
int total = list.Count; // Invalid Operation Exception
return new AjaxStoreActionResult(list, total);</description>
		<content:encoded><![CDATA[<p>@Venkat,</p>
<p>Try this then&#8230;</p>
<p>@Venkat,</p>
<p>Try changing it to this:</p>
<p>var query = (from o in this.DBContext.mvc_getSelectGrids_ForProgramCode(paramProgramCode, start, limit, ref total)<br />
select new<br />
{<br />
o.RgID,<br />
o.GridLayoutLocation,<br />
o.ObjectType,<br />
o.Label,<br />
o.AttribCodes<br />
});</p>
<p>var list = query.ToList();<br />
list = query.Skip(start).Take(limit).ToList();<br />
int total = list.Count; // Invalid Operation Exception<br />
return new AjaxStoreActionResult(list, total);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Venkat</title>
		<link>http://jonkruger.com/blog/2007/10/19/iqueryable-vs-ienumerable-in-linq-to-sql-queries/comment-page-1/#comment-3839</link>
		<dc:creator>Venkat</dc:creator>
		<pubDate>Wed, 24 Jun 2009 18:46:26 +0000</pubDate>
		<guid isPermaLink="false">http://jonkruger.com/blog/2007/10/19/iqueryable-vs-ienumerable-in-linq-to-sql-queries/#comment-3839</guid>
		<description>Jon:

Thanks for quick response. It did not solve the problem. 

This issue is in the same line as 
http://social.msdn.microsoft.com/Forums/en-US/linqprojectgeneral/thread/f403e047-e38c-45ab-9155-dbf83c6cc2fa</description>
		<content:encoded><![CDATA[<p>Jon:</p>
<p>Thanks for quick response. It did not solve the problem. </p>
<p>This issue is in the same line as<br />
<a href="http://social.msdn.microsoft.com/Forums/en-US/linqprojectgeneral/thread/f403e047-e38c-45ab-9155-dbf83c6cc2fa" rel="nofollow">http://social.msdn.microsoft.com/Forums/en-US/linqprojectgeneral/thread/f403e047-e38c-45ab-9155-dbf83c6cc2fa</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Kruger</title>
		<link>http://jonkruger.com/blog/2007/10/19/iqueryable-vs-ienumerable-in-linq-to-sql-queries/comment-page-1/#comment-3838</link>
		<dc:creator>Jon Kruger</dc:creator>
		<pubDate>Wed, 24 Jun 2009 16:57:07 +0000</pubDate>
		<guid isPermaLink="false">http://jonkruger.com/blog/2007/10/19/iqueryable-vs-ienumerable-in-linq-to-sql-queries/#comment-3838</guid>
		<description>@Venkat,

Try changing it to this:

var query = (from o in this.DBContext.mvc_getSelectGrids_ForProgramCode(paramProgramCode, start, limit, ref total)
select new
{
o.RgID,
o.GridLayoutLocation,
o.ObjectType,
o.Label,
o.AttribCodes
});

query = query.Skip(start).Take(limit); // I moved this line up
int total = query.ToList().Count; //  Invalid Operation Exception
return new AjaxStoreActionResult(query, total);</description>
		<content:encoded><![CDATA[<p>@Venkat,</p>
<p>Try changing it to this:</p>
<p>var query = (from o in this.DBContext.mvc_getSelectGrids_ForProgramCode(paramProgramCode, start, limit, ref total)<br />
select new<br />
{<br />
o.RgID,<br />
o.GridLayoutLocation,<br />
o.ObjectType,<br />
o.Label,<br />
o.AttribCodes<br />
});</p>
<p>query = query.Skip(start).Take(limit); // I moved this line up<br />
int total = query.ToList().Count; //  Invalid Operation Exception<br />
return new AjaxStoreActionResult(query, total);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Venkat</title>
		<link>http://jonkruger.com/blog/2007/10/19/iqueryable-vs-ienumerable-in-linq-to-sql-queries/comment-page-1/#comment-3837</link>
		<dc:creator>Venkat</dc:creator>
		<pubDate>Wed, 24 Jun 2009 16:50:59 +0000</pubDate>
		<guid isPermaLink="false">http://jonkruger.com/blog/2007/10/19/iqueryable-vs-ienumerable-in-linq-to-sql-queries/#comment-3837</guid>
		<description>Jon:
I have an issue may be you can help me. I am using ASP.Net MVC (Coolite Controls) LINQ to SQL using StoredProcedure with Paging. Code is as below.


Controller Call:
------------------
public AjaxStoreActionResult GetSelectRefGrids(int limit, int start, string dir, string sort, int paramProgramCode)


Case 1:
--------------

var query = (from o in this.DBContext.mvc_getSelectGrids_ForProgramCode(paramProgramCode, start, limit, ref total)
                         select new
                         {
                             o.RgID,
                             o.GridLayoutLocation,
                             o.ObjectType,
                             o.Label,
                             o.AttribCodes
                         });   

	int total = query.ToList().Count;   // &#60;&#62; Invalid Operation Exception
	query = query.Skip(start).Take(limit);
	return new AjaxStoreActionResult(query, total);


&#62;&#62; The Code fails returning Error as "Message = "The query results cannot be enumerated more than once."
&#62;&#62;
&#62;&#62; So I changed Stored Procedure to Handle Paging and Return Total as OUT param 

Case 2:
-------------------

System.Nullable total = null
var query = (from o in this.DBContext.mvc_getSelectGrids_ForProgramCode(paramProgramCode, start, limit, ref total)
                         select new
                         {
                             o.RgID,
                             o.GridLayoutLocation,
                             o.ObjectType,
                             o.Label,
                             o.AttribCodes
                         });   
	return new AjaxStoreActionResult(query, total);


&#62;&#62; Any suggestions go by Case 1 and to handle the error "The query results cannot be enumerated more than once." - Thanks Venkat</description>
		<content:encoded><![CDATA[<p>Jon:<br />
I have an issue may be you can help me. I am using ASP.Net MVC (Coolite Controls) LINQ to SQL using StoredProcedure with Paging. Code is as below.</p>
<p>Controller Call:<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
public AjaxStoreActionResult GetSelectRefGrids(int limit, int start, string dir, string sort, int paramProgramCode)</p>
<p>Case 1:<br />
&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>var query = (from o in this.DBContext.mvc_getSelectGrids_ForProgramCode(paramProgramCode, start, limit, ref total)<br />
                         select new<br />
                         {<br />
                             o.RgID,<br />
                             o.GridLayoutLocation,<br />
                             o.ObjectType,<br />
                             o.Label,<br />
                             o.AttribCodes<br />
                         });   </p>
<p>	int total = query.ToList().Count;   // &lt;&gt; Invalid Operation Exception<br />
	query = query.Skip(start).Take(limit);<br />
	return new AjaxStoreActionResult(query, total);</p>
<p>&gt;&gt; The Code fails returning Error as &#8220;Message = &#8220;The query results cannot be enumerated more than once.&#8221;<br />
&gt;&gt;<br />
&gt;&gt; So I changed Stored Procedure to Handle Paging and Return Total as OUT param </p>
<p>Case 2:<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>System.Nullable total = null<br />
var query = (from o in this.DBContext.mvc_getSelectGrids_ForProgramCode(paramProgramCode, start, limit, ref total)<br />
                         select new<br />
                         {<br />
                             o.RgID,<br />
                             o.GridLayoutLocation,<br />
                             o.ObjectType,<br />
                             o.Label,<br />
                             o.AttribCodes<br />
                         });<br />
	return new AjaxStoreActionResult(query, total);</p>
<p>&gt;&gt; Any suggestions go by Case 1 and to handle the error &#8220;The query results cannot be enumerated more than once.&#8221; - Thanks Venkat</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL Tutorials</title>
		<link>http://jonkruger.com/blog/2007/10/19/iqueryable-vs-ienumerable-in-linq-to-sql-queries/comment-page-1/#comment-3777</link>
		<dc:creator>SQL Tutorials</dc:creator>
		<pubDate>Fri, 01 May 2009 02:34:03 +0000</pubDate>
		<guid isPermaLink="false">http://jonkruger.com/blog/2007/10/19/iqueryable-vs-ienumerable-in-linq-to-sql-queries/#comment-3777</guid>
		<description>You know, the thing about SQL is, that there is virtually nothing that can replace it. 

Does anyone know if a substitute exists for sql? I mean besides MS SQL and Oracle and all that jazz. Thanks.</description>
		<content:encoded><![CDATA[<p>You know, the thing about SQL is, that there is virtually nothing that can replace it. </p>
<p>Does anyone know if a substitute exists for sql? I mean besides MS SQL and Oracle and all that jazz. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: IEnumerable vs IQuerable &#171; Paris Polyzo&#8217;s Weblog</title>
		<link>http://jonkruger.com/blog/2007/10/19/iqueryable-vs-ienumerable-in-linq-to-sql-queries/comment-page-1/#comment-3117</link>
		<dc:creator>IEnumerable vs IQuerable &#171; Paris Polyzo&#8217;s Weblog</dc:creator>
		<pubDate>Tue, 18 Nov 2008 13:09:39 +0000</pubDate>
		<guid isPermaLink="false">http://jonkruger.com/blog/2007/10/19/iqueryable-vs-ienumerable-in-linq-to-sql-queries/#comment-3117</guid>
		<description>[...] IEnumerable vs&#160;IQuerable Watch the following article:IEnumerable&#60;T&#62; vs IQueryable&#60;T&#62; [...]</description>
		<content:encoded><![CDATA[<p>[...] IEnumerable vs&nbsp;IQuerable Watch the following article:IEnumerable&lt;T&gt; vs IQueryable&lt;T&gt; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Kruger</title>
		<link>http://jonkruger.com/blog/2007/10/19/iqueryable-vs-ienumerable-in-linq-to-sql-queries/comment-page-1/#comment-2815</link>
		<dc:creator>Jon Kruger</dc:creator>
		<pubDate>Fri, 21 Dec 2007 02:45:35 +0000</pubDate>
		<guid isPermaLink="false">http://jonkruger.com/blog/2007/10/19/iqueryable-vs-ienumerable-in-linq-to-sql-queries/#comment-2815</guid>
		<description>WebGyver-

I'm in a similar situation as you in that I was rewriting a legacy application.  I have been very impressed with LINQ to SQL and I would highly recommend it.  We are working with a legacy database (SQL Server 2005) that has some really unusual stuff in it, and LINQ to SQL has been able to handle it all.

IMO, if you want to get all of the benefits out of LINQ to SQL (or any ORM for that matter), I would try and get away from the stored procedures and allow LINQ to SQL to handle all the work.  LINQ to SQL will optimize all of the queries for you, and if you do have a situation where you need to use stored procs, LINQ to SQL can wrap those nicely for you so that  calling the stored proc is as easy as calling a method.

Good luck!

Jon</description>
		<content:encoded><![CDATA[<p>WebGyver-</p>
<p>I&#8217;m in a similar situation as you in that I was rewriting a legacy application.  I have been very impressed with LINQ to SQL and I would highly recommend it.  We are working with a legacy database (SQL Server 2005) that has some really unusual stuff in it, and LINQ to SQL has been able to handle it all.</p>
<p>IMO, if you want to get all of the benefits out of LINQ to SQL (or any ORM for that matter), I would try and get away from the stored procedures and allow LINQ to SQL to handle all the work.  LINQ to SQL will optimize all of the queries for you, and if you do have a situation where you need to use stored procs, LINQ to SQL can wrap those nicely for you so that  calling the stored proc is as easy as calling a method.</p>
<p>Good luck!</p>
<p>Jon</p>
]]></content:encoded>
	</item>
</channel>
</rss>

