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

RadGrid + Entity Framework executes Query 3 times

4 Answers 61 Views
Grid
This is a migrated thread and some comments may be shown as answers.
orim
Top achievements
Rank 1
orim asked on 20 Dec 2012, 10:47 AM
Hi,
My Environment: VS 2010 SP 1, EF 4/5, Teleri RadControls AJAC Q3 SP1 - 12.3.1205.0

Protected Sub RadGrid1_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
 
        Dim d As New Ares4AgsmEntities
 
        Dim q = From i In d.Computer
                Select i.SamAccountName, i.SerialNumber
 
        RadGrid1.DataSource = q
 
 
 
    End Sub
Bind RadGrid to EF context executes the same query 3 times (see SQL Profiler). I also bind GridView to EF context this executs query 1 time.
Bind RadGrid to EntityDatasource this executes the query 1 time.
Whats the problem ? Is this a default behavior ?

4 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 25 Dec 2012, 09:56 PM
Hello,

May I ask you to open a formal support ticket and send us a sample runnable project where the described problem can be observed. We will debug it locally and will advice you further.

Greetings,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Huy Viet
Top achievements
Rank 1
answered on 30 Oct 2015, 08:03 PM

I have a similar issue, the SQL profiler show 3 calls with the same query.

In the ASPX we have a grid:

<telerik:RadGrid ID="ProjectsGrid" runat="server"
OnNeedDataSource="Project_NeedDataSource"
AllowSorting="true"
AutoGenerateColumns="false"
AllowFilteringByColumn="true"
GridLines="None"
OnItemDataBound="DetailsGrid_ItemDataBound"
Height="99%" >

where in our aspx.cs, the call back is define like this:

protected Project_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)

{

RadGrid grid = sender as RadGrid;
SqlDataSource sql = new SqlDataSource();

...

grid.DataSource = sql;

}

Our environment: VS 2013 with the latest version of Telerik.

Any insight?

0
Joe
Top achievements
Rank 2
answered on 04 Nov 2015, 01:52 PM
I had the same issue. I think it depends on how everything is setup. I know that my MVC app will run all of those things twice. Webform app with RadGrid does it three times. As a temporary measure I copied the data results to a memory cache and pass that back rather than doing more db calls. I think it has something to do with having the db calls in the view itself.
0
Huy Viet
Top achievements
Rank 1
answered on 04 Nov 2015, 09:11 PM

Thanks Joseph for the reply, Will investigate copying the data results to a memory cache.

We have tried to use the EntityDataSource instead, but it wouldn't work (or at least we don't see how) as our SQL Queries have "COLLATE" and also access two DBs in a single query.

Using an asp:GridView, would be a major redesign, and I'm not sure it has all the fonctionnality of the RadGrid, so we would like to find a solution with the RadGrid, Is-it possible to configure a RadGrid with a SQLDataSource so that it does not query 3 times the DB?

Tags
Grid
Asked by
orim
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Huy Viet
Top achievements
Rank 1
Joe
Top achievements
Rank 2
Share this question
or