When using the devexpress gridview's bindtoLINQ functionality it queries the entire table set instead of the page the client is looking at.
IE. using SQL Server Profiler, we see it selects all columns of the 200k+ rows in the table instead of just the intended 10.
The view looks like this:
@Html.DevExpress().GridView(...).BindToLINQ("MyProject.Models.DBEntities", "myTable", (s, e) => { e.KeyExpression = "row_id"; }).GetHtml()
The grid does come out well-formatted client-side but since it appears to select the entire dataset inside my table any type of action the client executes will perform way too poorly- just going to the next page will take approx. 15 seconds. Why doesn't the gridview use a LIMIT and pagerow to only select the necessary data that is visible to the client? It only seems to use the Linq Skip and Take commands after selecting the entire table contents.
This is another way I tried it but it behaves similarly:
// the ActionResult function inside my controller:
public ActionResult GridViewPartial() {
DBEntities dbEntities = new DBEntities();
var myLinqQuery = from s in dbEntities.myTable select new { s.row_id, s.row_username };
return PartialView("GridViewPartial", myLinqQuery);
}
// inside the Razor view:
@model IQueryable
@Html.DevExpress().GridView(...).BindToLINQ("", "", (s, e) => { e.KeyExpression = "row_id"; e.QueryableSource = Model; }).GetHtml()
Alternatively, using Bind() instead of BindToLINQ() does the same thing:
// inside the Razor view:
@model IQueryable
@Html.DevExpress().GridView(...).Bind(Model).GetHtml()