Domanda

I have written the following method attempting to extend IQueryable<T> to provide generic paging that integrates with my custom pager control. But, when I attempt to call the method on an IQueryable<Account>, I get the following Compiler Error:

BC30456: 'Page' is not a member of 'System.Linq.IQueryable(Of OrgName.ProjName.Account)'.

Source:

Imports System.Runtime.CompilerServices

Module Paging
    <Extension()>
    Public Function Page(Of T)(source As IQueryable(Of T), pageIndex As Integer, pageSize As Integer, ByRef recordCount As Integer) As IQueryable(Of T)
        recordCount = source.Count()
        Return source.Skip(pageIndex * pageSize).Take(pageSize)
    End Function
End Module

The module file is in the same assembly and namespace as the Account business object (OrgName.ProjName). (Names have been changed to protect the innocent.)

I'm not sure how the above is any different than the accepted answer in this question (other than language, obviously): Transform LINQ IQueryable into a paged IQueryable using LINQ to NHibernate

Any idea what I'm doing wrong?

È stato utile?

Soluzione

Make sure your module is Public, and also make sure to use the appropriate "Imports" statement in the file where you want to use the extension method.

Cheers

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top