Reputation: 3816
I'm using KendoUI grid and using its ToDataSourceResult to filter my data (as suggested by the documentation) but i'm worried about the performance impact.
Based on my understanding, the following suggested code get all records from database into memory and performm ToDataSourceResult extension method to filter the records in memory (LINQ fluent api concept). Will this have great performance impact if i have lots of records?
I suppose having a query to the database with the "where" clause upfront will have better performance... please advise.
Here's what suggested in the documentation
var countries = _database.Countries.GetAll();
return Json(countries.ToDataSourceResult(request, record => new
{
record.Id,
record.Name,
record.Currency,
record.TimeZone
}));
This is other option without using ToDataSource filter
var selectedCountries = _database.Countries.GetCountryStartWith("m")
Upvotes: 3
Views: 1384
Reputation: 30671
It depends on what your GetAll
method returns. If it returns IQueryable
from a LINQ-enabled provider (Entity Framework, Linq to SQL or anything else) all operations will be performed at database level (not in memory). If it returns all records - well you have a problem even before using ToDataSourceResult.
Upvotes: 6