我有一個KendoGrid,我設置與該事件數據源讀取:劍道格,ToDataSouceResult與EF4
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,需要一點時間,而不是大量的記錄,它需要很多時間...
我忘記了什麼?
我建議你結合分頁早很多代入公式。只選擇你需要的東西。 –
我認爲用ToDataSourceResult(),我不需要任何'Take()'在我的查詢中... – Berry