Page 1 of 1

Sorting Linq Query Objects

Posted: Wed 20 May 2009 14:02
by Colbotron
I have a Linq Query stored in session and bound to a gridview like this:

Code: Select all

gvResults.DataSource = persons
gvResults.DataBind()
Session("PERSONS") = persons
Each Time a user clicks a column header, I would like to sort the query. This would be the normal way I would do it if it was a dataTable stored in session:

Code: Select all

        
Dim dt As DataTable = Session("PERSONS")
Dim dv As DataView = New DataView(dt)
dv.Sort = sortEx
'Save back to Session so paging functionality remains
Session("PERSONS") = dv.ToTable()
gvResults.DataSource = Session("PERSONS")
gvResults.DataBind()
What is the alternative way to make this work with LINQ?

Posted: Thu 21 May 2009 11:48
by AndreyR
You will need to implement something like the method described here:
http://technoesis.wordpress.com/2008/03 ... libraries/