<?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: Dynamic Sort With LINQ To SQL</title>
	<atom:link href="http://www.onedotnetway.com/dynamic-sort-with-linq-to-sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.onedotnetway.com/dynamic-sort-with-linq-to-sql/</link>
	<description>Everything .Net</description>
	<lastBuildDate>Mon, 09 Jan 2012 00:09:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Dhaval</title>
		<link>http://www.onedotnetway.com/dynamic-sort-with-linq-to-sql/comment-page-1/#comment-5669</link>
		<dc:creator>Dhaval</dc:creator>
		<pubDate>Sun, 21 Jun 2009 05:54:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.onedotnetway.com/dynamic-sort-with-linq-to-sql/#comment-5669</guid>
		<description>Deepak,

There seems to be big difference between your first GetSortedEmployees function and your last one, the one that takes Lamda Expression as an argument.  The problem with the last one, you can&#039;t simply pass in a string columnname and simply do the sort.  for example.

if my function was simply sending in columnname as string:

Function GetEmployees(sortBy as String) as List(Of Employees)

&#039;I would have to do a select case to use your lamda expression function

SELECT CASE sortBy

case &quot;CreatedDate&quot;

return GetSortedEmployees(Of Employee)(Function(e) e.CreatedDate).ToList()

Case &quot;Name&quot;

return GetSortedEmployees(Of Employee)(Function(e) e.Name).ToList()

End Select

End Function

So, your last function altough simple, isnt truely dynamic.  I am wondering if there is a way to write the last function so that it takes sortby columnname as string and returns a sorted iQueryable.

Thanks.

Dhaval</description>
		<content:encoded><![CDATA[<p>Deepak,</p>
<p>There seems to be big difference between your first GetSortedEmployees function and your last one, the one that takes Lamda Expression as an argument.  The problem with the last one, you can&#8217;t simply pass in a string columnname and simply do the sort.  for example.</p>
<p>if my function was simply sending in columnname as string:</p>
<p>Function GetEmployees(sortBy as String) as List(Of Employees)</p>
<p>&#8216;I would have to do a select case to use your lamda expression function</p>
<p>SELECT CASE sortBy</p>
<p>case &#8220;CreatedDate&#8221;</p>
<p>return GetSortedEmployees(Of Employee)(Function(e) e.CreatedDate).ToList()</p>
<p>Case &#8220;Name&#8221;</p>
<p>return GetSortedEmployees(Of Employee)(Function(e) e.Name).ToList()</p>
<p>End Select</p>
<p>End Function</p>
<p>So, your last function altough simple, isnt truely dynamic.  I am wondering if there is a way to write the last function so that it takes sortby columnname as string and returns a sorted iQueryable.</p>
<p>Thanks.</p>
<p>Dhaval</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deepak</title>
		<link>http://www.onedotnetway.com/dynamic-sort-with-linq-to-sql/comment-page-1/#comment-583</link>
		<dc:creator>Deepak</dc:creator>
		<pubDate>Sun, 07 Dec 2008 11:29:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.onedotnetway.com/dynamic-sort-with-linq-to-sql/#comment-583</guid>
		<description>Levi,

I will send you the sample project shortly.</description>
		<content:encoded><![CDATA[<p>Levi,</p>
<p>I will send you the sample project shortly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Levi</title>
		<link>http://www.onedotnetway.com/dynamic-sort-with-linq-to-sql/comment-page-1/#comment-566</link>
		<dc:creator>Levi</dc:creator>
		<pubDate>Fri, 05 Dec 2008 22:11:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.onedotnetway.com/dynamic-sort-with-linq-to-sql/#comment-566</guid>
		<description>Hello again Deepak,
Is there any way you could post the sample project or perhaps send it to me? My business partner and I are still struggling to get sorting to work with our linq statements and it would help us understand if there is something we are missing. I know it may be a lot to ask, so for your troubles I&#039;d be happy to give you one free icon collection if you are interested. My site is http://www.professional-icons.com &gt;&gt; Thanks!

Levi</description>
		<content:encoded><![CDATA[<p>Hello again Deepak,<br />
Is there any way you could post the sample project or perhaps send it to me? My business partner and I are still struggling to get sorting to work with our linq statements and it would help us understand if there is something we are missing. I know it may be a lot to ask, so for your troubles I&#8217;d be happy to give you one free icon collection if you are interested. My site is <a href="http://www.professional-icons.com" rel="nofollow">http://www.professional-icons.com</a> &gt;&gt; Thanks!</p>
<p>Levi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deepak</title>
		<link>http://www.onedotnetway.com/dynamic-sort-with-linq-to-sql/comment-page-1/#comment-466</link>
		<dc:creator>Deepak</dc:creator>
		<pubDate>Thu, 20 Nov 2008 23:21:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.onedotnetway.com/dynamic-sort-with-linq-to-sql/#comment-466</guid>
		<description>Hi Levi,

Make sure that you have reference to System.Data.Linq

and following using statements other than the ones in a standard Windows Forms application (I used Win Forms app as my test harness)

System.Linq
System.Linq.Expressions</description>
		<content:encoded><![CDATA[<p>Hi Levi,</p>
<p>Make sure that you have reference to System.Data.Linq</p>
<p>and following using statements other than the ones in a standard Windows Forms application (I used Win Forms app as my test harness)</p>
<p>System.Linq<br />
System.Linq.Expressions</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Levi</title>
		<link>http://www.onedotnetway.com/dynamic-sort-with-linq-to-sql/comment-page-1/#comment-465</link>
		<dc:creator>Levi</dc:creator>
		<pubDate>Thu, 20 Nov 2008 22:58:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.onedotnetway.com/dynamic-sort-with-linq-to-sql/#comment-465</guid>
		<description>Hello Deepak,

For some reason I can&#039;t get this to compile. Could you tell me what DLL references and namespaces I should be using? I think i may be missing one but can&#039;t seem to figure out which one.

Thanks!
Levi</description>
		<content:encoded><![CDATA[<p>Hello Deepak,</p>
<p>For some reason I can&#8217;t get this to compile. Could you tell me what DLL references and namespaces I should be using? I think i may be missing one but can&#8217;t seem to figure out which one.</p>
<p>Thanks!<br />
Levi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deepak</title>
		<link>http://www.onedotnetway.com/dynamic-sort-with-linq-to-sql/comment-page-1/#comment-461</link>
		<dc:creator>Deepak</dc:creator>
		<pubDate>Thu, 20 Nov 2008 11:21:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.onedotnetway.com/dynamic-sort-with-linq-to-sql/#comment-461</guid>
		<description>Fatih,

You are trying to access GetSortedEmployees method from a static method. You can either make GetSortedEmployees a static method or move your data access code to another class and call the method on an instance of that class.

If this does not help you then post some code and I&#039;ll have a look.</description>
		<content:encoded><![CDATA[<p>Fatih,</p>
<p>You are trying to access GetSortedEmployees method from a static method. You can either make GetSortedEmployees a static method or move your data access code to another class and call the method on an instance of that class.</p>
<p>If this does not help you then post some code and I&#8217;ll have a look.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fatih</title>
		<link>http://www.onedotnetway.com/dynamic-sort-with-linq-to-sql/comment-page-1/#comment-459</link>
		<dc:creator>Fatih</dc:creator>
		<pubDate>Thu, 20 Nov 2008 10:41:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.onedotnetway.com/dynamic-sort-with-linq-to-sql/#comment-459</guid>
		<description>Hi,
Thanks for this great code but i&#039;ve a problem with this.

When i call GetSortedEmployees(x=&gt;x.Title),i&#039;m getting an error like &quot; cannot access non-static method &#039;GetSortedEmployees&#039; in static context&quot;.How can i get rid of this problem?

Thx.</description>
		<content:encoded><![CDATA[<p>Hi,<br />
Thanks for this great code but i&#8217;ve a problem with this.</p>
<p>When i call GetSortedEmployees(x=&gt;x.Title),i&#8217;m getting an error like &#8221; cannot access non-static method &#8216;GetSortedEmployees&#8217; in static context&#8221;.How can i get rid of this problem?</p>
<p>Thx.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deepak</title>
		<link>http://www.onedotnetway.com/dynamic-sort-with-linq-to-sql/comment-page-1/#comment-456</link>
		<dc:creator>Deepak</dc:creator>
		<pubDate>Thu, 20 Nov 2008 02:10:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.onedotnetway.com/dynamic-sort-with-linq-to-sql/#comment-456</guid>
		<description>Levi,

Thanks for kind words.</description>
		<content:encoded><![CDATA[<p>Levi,</p>
<p>Thanks for kind words.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Levi</title>
		<link>http://www.onedotnetway.com/dynamic-sort-with-linq-to-sql/comment-page-1/#comment-455</link>
		<dc:creator>Levi</dc:creator>
		<pubDate>Thu, 20 Nov 2008 01:47:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.onedotnetway.com/dynamic-sort-with-linq-to-sql/#comment-455</guid>
		<description>Wow, thanks so much for putting this together. I&#039;ll give this a shot and let you know how it goes!</description>
		<content:encoded><![CDATA[<p>Wow, thanks so much for putting this together. I&#8217;ll give this a shot and let you know how it goes!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

