Cannot implicitly convert type 'System.Collections.Generic.List<T>' to 'System.Linq.IQueryable<T>'

孤街醉人 提交于 2019-12-03 07:12:35

The problem is precisely because you've called ToList(). You've declared that you're returning IQueryable<LocationStatusList>, and List<T> doesn't implement IQueryable<T>.

Options (pick one):

  • Remove the ToList call
  • Change the return type to IEnumerable<LocationStatusList>, IList<LocationStatusList> or possibly List<LocationStatusList>
  • Call AsQueryable() after ToList():

    ... as before ...
    .ToList().AsQueryable();
    

Note that you don't need the type argument in the ToList call - it's the same one that the compiler would infer anyway.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!