我試圖在超過10萬條記錄上實現搜索功能。這是使用PagedList時遇到速度問題。PagedList搜索遭受效率低下
public ActionResult CrmBlogGroupType(int? page, bool? Name, bool? AuthorTitle, bool? Description, string search, int? PageSize, string type)
{
try
{
if (type==null)
{
type = "A";
}
IEnumerable<Usp_getBlogSetPosts_Result> _objBlogSet = _dataLayer.GetBlogSet(type);
//The above _objBlogSet has around 10 thousand records
ViewBag.CurrentPage = page;
ViewBag.Name = Name ==null?false:Name;
ViewBag.AuthorTitle = AuthorTitle == null ? false : AuthorTitle;
ViewBag.Description = Description == null ? false : Description;
ViewBag.Search = search;
ViewBag.type = type;
if (Name == true && AuthorTitle == false && Description == false)
{
_objBlogSet = _objBlogSet.Where(p => p.author_name.ToLower().Contains(search.ToLower())).ToPagedList(page ?? 1, PageSize ?? 10);
}
return View(_objBlogSet);
catch (Exception ex)
{
throw ex;
}
}
公開名單 Get_MVP_Consultants() { 列表 obj_Consultants = _dbContext.Tbl_MVPConsultant.Where(p值=> p.Visibility == TRUE).ToList(); return obj_Consultants; } 上面是數據層方法,我得到的數據..我如何修改該代碼爲IQueryable .. –
Dathatreya
不要轉換該列表。只要你這樣做,數據庫被擊中,一切都會被返回。 – lusocoding
嗨@lusocoding我跟着你的意見,並改變了我的Datalayer方法返回IQueryable結果..但ToPagedList()方法不允許Iqueryable結果..如何現在進行.. – Dathatreya