LINQ to Entities ToString() - None of the proposed solutions work?

我们两清 提交于 2019-12-04 06:41:23

Materialize the query before you invoke ToString will make the last part a non linq-to-entities query. You could optimize this by only selecting the id and description, then calling AsEnumerable, and then getting the selectlistitems.

    return new DataAccess() 
        .Categories 
        .OrderBy(c => c.Description)
        .AsEnumerable()
        .Select(c => new SelectListItem 
            { 
                Value = c.Id.ToString(), 
                Text = c.Description 
            }); 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!