我正在使用LINQ查詢,我正在按升序列出項目。我需要從列表中獲取最新的4個項目。從列表中獲取最新/最後一項,升序
我有加載更多按鈕,onclick應該從列表中獲得前4項。
var GetALLFields =(from post in dbContext.PostTable
join com in dbContext.CommentTable on post.PostID equals com.PostedId
join user in dbContext.UserTable on com.commenterID equals user.userId
where (com.PostedId == PostID)
select new
{
PostId = post.PostID,
commentId = com.commentID,
CommenterID = user.userId,
name = user.Name,
commenterUserName = user.userName,
Imagebase64 = user.userImageBase64,
ImageType = user.userImagetype,
commentId = post.PostedDataID,
commentcreatedAt = com.createdAt,
commenterDelete = com.commenterDelete,
});
if (GetALLFields != null)
{
//PageSize I am getting from ajax (first it be 0 then pageSize will be multple of 4)
GetALLComment = GetALLFields.OrderBy(x=>x.createdAt).Skip(PageSize).Take(4).Reverse().ToList();
GetALLComment.Reverse();
}
的onpage負載,我需要從列表
7
8
9
10
的OnClick加載更多的獲得最新/最後的4個項目,我需要獲得以前的4個最新的4項
3
4
5
6
7
8
9
10
沿項目
所以你需要結果加起來嗎? –
如果是這樣的話,你可以在你填寫的地方發佈ajax。那就是你需要編輯的地方!這段代碼正在做它的工作! –
您的實際問題比 –