我有一个 KendoGrid,我将数据源设置为事件读取:
public virtual JsonResult ContactsListRead([DataSourceRequest] DataSourceRequest request)
{
return Json(ContactsModel.ContactsService.Get().ToDataSourceResult(request));
}
ContactsModel.ContactsService.Get() 方法,返回一个 IQueryable:
var qContactsOpen = from x in promo.Contacts
where x.type == type && (x.closure_id == 0 || x.closure_id == null)
orderby x.id descending
select new ContactsGrid
{
Id = x.id,
DescriptionA = x.description_A,
Address = x.address,
PhoneA = x.phone_A,
CategoryDescription = x.Categories.description,
Location = x.location,
Subject = x.subject,
Note = x.ContactsActivities.Where(o=>o.promotion_id == promo.id).OrderByDescending(o => o.date).Select(o => o.note).FirstOrDefault() ?? "",
};
return (qContactsOpen.AsQueryable());
在网格上我有分页(20),所以,我希望无论查询中的记录数是多少,ContactsListRead,都需要一点时间,而不是大量的记录需要很多时间......
我忘记了什么?