Sorting Linq Query Objects

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
Colbotron
Posts: 2
Joined: Wed 20 May 2009 13:49

Sorting Linq Query Objects

Post by Colbotron » Wed 20 May 2009 14:02

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?

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Thu 21 May 2009 11:48

You will need to implement something like the method described here:
http://technoesis.wordpress.com/2008/03 ... libraries/

Post Reply