我有一个IQueryable存储库(不可否认这是我第一次尝试这个)而且我似乎无法使用Skip(1).Take(1)
这是存储库
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
这是服务
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
问题是它在Order By子句中返回 FIRST 记录,而不是 SECOND 。
谁能告诉我这里我做错了什么?
答案 0 :(得分:2)
你确定是吗?为什么不将调用分开并在调试模式中查看结果...
var list = _ActivityLogRepository.GetActivity().Where(Function(a) a.UserID = UserID);
var skipped = list.Skip(1);
var taken = skipped.Take(1);
return taken;