views:

15

answers:

1

I've got an IQueryable repository (admittedly this is the first time I've tried this) and I can't seem to get it to pull the correct data using Skip(1).Take(1)

Here's the repository

    Public Function GetActivity() As IQueryable(Of ActivityLog) Implements IActivityLogRepository.GetActivity
        Dim activity = (From a In dc.ActivityLogs
                        Order By a.ActivityDate Descending
                        Select a).AsQueryable
        Return activity
    End Function

And here's the Service

    Public Function GetUsersLastActivity(ByVal UserID As Integer) As ActivityLog Implements IActivityLogService.GetUsersLastActivity
        Return _ActivityLogRepository.GetActivity().Where(Function(a) a.UserID = UserID).Skip(1).Take(1)
    End Function

The problem is that it's returning the FIRST record in the Order By clause and not the SECOND.

Can anyone tell me what I'm doing wrong here?

+1  A: 

Are you sure it is? Why don't you separate the calls and look at the results in debug mode...

var list = _ActivityLogRepository.GetActivity().Where(Function(a) a.UserID = UserID);
var skipped = list.Skip(1);
var taken = skipped.Take(1);
return taken;
Chad
turns out that the Controller call wasn't using the method that it was originally using... oops.
rockinthesixstring