Now, we've switched our software to use Entity Framework with Automapper doing those mappings. The grid is no longer requesting the top x results from the query and this is causing an 1100 item recordset to take almost 4 seconds to show. The actual query is taking 3.6 seconds of that because of all the join data I'm pulling through for the model. Is there something I'm missing preventing the grid from paging the data?
5 Answers, 1 is accepted
I've run the software through EFProfiler, and even though I see that the enumeration isn't happening until the screen is being rendered, there's no Skip(x).Take(x) occurring. I'm getting 1400 items back and the grid is only displaying 10.
I have to map the objects coming out of the database, so I don't know what is going wrong.
The grid will uses the IQueryable extension methods to page the data. If you however pass it an IList or force execution of the IQueryable by calling Count() or ToList() or ToArray() - the grid won't hit the database at all after that. Without seeing your code we cannot be sure what is really happening.
You can try calling Take() and Skip() manually and see what happens with the profiler.
the Telerik team
I read a recommendation by telerik on not returning entities right up to the screens, because the moment you use the Ajax select, you get a circular reference in the serialization. The recommendation was to map the objects. So, how do I map, yet still allow IQueryable from Entity Framework?
If I use automapper, I get an error about not being able to convert Map to a store expression. If I hand code the objects, I'm ok, however if my database stores a integer and I want a timespan on the view, I can't do this because I can't use a new TimeSpan in the select clause of the EF.
I am afraid your only option is to implement custom binding. Manual mapping will work as long as you don't add additional properties.Regards,
the Telerik team
I thought I should update this post in order that someone else should read it with the same question.