简体   繁体   中英

ToList() taking too long to execute

I am beginner in asp.net and I am working with a asp.net website in sitefinity. There is a custom widget on a page because of which the page load time drops to 2 mins.

After lot of research I found that ToList() could be the reason for this slowness. Below is the C# code of the widget containing the ToList().

namespace SitefinityWebApp.CustomControls
{
    public partial class DashboardRole : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            List<bl.CustomItem> classificationList = bl.module.GetClassifications(bl.config.classification_assets_name, "", bl.config.data_asset_content_type);
            classificationList = classificationList.OrderByDescending(o => o.ItemsCount).ToList();
            rptMainClassifications.DataSource = classificationList;
            rptMainClassifications.DataBind();
        }
    }
}

Is there anyone have faced such issue earlier. Any help would mean a lot.

Edit : This is how GetClassifications() looks like https://i.stack.imgur.com/OsnrW.jpg

I'm pretty sure that this is not because of ToList() method.
ToList() just convert your IEnumerable() or other list to simple c# List().
There is another problem. And your question have not enough content to understand the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM