Can't access any of Linq methods

I'm writing a simple ApiController for getting product stocks, but I'm having a strange issue. I get the data from a method that returns a System.Linq.IQueryable (In a library), but I can't apply any of the Linq methods, like Count or ToList(). The import directive is present and doesn't report any problem. Also intellisense shows Data as System.Linq.IQueryable.

The code:

Imports System.Web.Http
Imports System.Linq

Public Class ProductSearchController
    Inherits ApiController

    Public Function Get(...) As IQueryable

        Dim nvc As NameValueCollection = HttpUtility.ParseQueryString(Request.RequestUri.Query)
        Dim sEcho As String = nvc("sEcho").ToString()
        Dim iDisplayStart As Integer = CType(nvc("iDisplayStart"), Integer)

        'Signature of Stock:  public IQueryable Stock(...)
        Dim Data = New GenericSearches().Stock(...)
        Dim Count As Integer = Data.Count() 'Error Here!

        Dim result = New DataTableResult With {
            .sEcho = sEcho,
            .iTotalRecords = Count,
            .iTotalDisplayRecords = Count,
            .aaData = Data.ToList() 'Error Here!
            }
        Return result
    End Function
End Class

Also, I noticed that error correction and intellisense asks me to choose those methods from a weird Devexpress library something like DevXpress.Data.Helpers.Linq.

Jon Skeet
people
quotationmark

The non-generic IQueryable interface doesn't have extension methods of Count and ToList(). Only the generic IQueryable<T> does.

If you can modify the library to return a suitable IQueryable<T>, I suggest you do so. If you can't, you may need to call Cast<T>() or OfType<T>() to create an appropriate IQueryable<T> with the right extension methods.

people

See more on this question at Stackoverflow