This is a migrated thread and some comments may be shown as answers.

Using Linq To SQL datasource

1 Answer 209 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Developer asked on 15 Apr 2010, 04:49 PM
Typically I use a Dataset object and store a table in Session for RadGrid's datasource.  I have been using Linq To Sql lately but I cannot figure out how to  use Linq for the datasourse in Session for the RadGrid....for example, how would I convert the following code to using Linq?

    Protected Sub radGridExperts_NeedDataSource(ByVal source As ObjectByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles radGridExperts.NeedDataSource  
        If Not IsNothing(Session("Experts")) Then 
            radGridExperts.DataSource = CType(Session("Experts"), Case_Inquiry.Case_ExpertsDataTable)  
            'do not fill anything, but create blank datasource  
            Dim dt As New Case_Inquiry.Case_ExpertsDataTable  
            Session("Experts") = dt  
            radGridExperts.DataSource = dt  
        End If 
    End Sub 

To make it simple, lets assume this is the linq Query.

Dim query = From c in db.Case_Experts _
        Select c.Id, c.Name

Also assume that I want to do updates/inserts/deletes to the data.

Appreciate any help, thank you.


1 Answer, 1 is accepted

Sort by
Telerik team
answered on 20 Apr 2010, 10:47 AM

Basically, the control will populate with data as expected, for as long as you pass the proper datasource in the NeedDataSource event handler. Nevertheless, the following link contains additional information on how to construct the query, and setup the LINQ to SQL Entities from the code behind:

I hope it gets you started properly.

Sincerely yours,
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question