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

后端 未结 1 1631
暗喜
暗喜 2021-02-08 11:58

I am trying to create a query in my domain service (VS 2010 Silverlight Business Application) that returns the results from inspection readings that came out as a specific value

相关标签:
1条回答
  • 2021-02-08 12:17

    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.

    0 讨论(0)
提交回复
热议问题