【发布时间】:2021-09-14 10:57:44
【问题描述】:
我有当前在线的用户列表:
List<int> onlineUsers = _connectedUsersEntity.GetOnlineIds();
然后我提出请求:
var profiles = await _cnx.Users
.OrderBy(p => onlineUsers.Any(z => z == p.Id))
.ThenBy(p => p.Id)
.Select(p => new { p.Id, p.DisplayName, p.ProfilePhoto })
.Skip(request.Skip)
.Take(request.Take)
.ToListAsync();
我想拥有:
//skip 0 take 3
{"user1":"online"}
{"user3":"online"}
{"user2":"offline"}
//then next call skip 3, take 3
{"user4":"offline"}
{"user5":"offline"}
{"user6":"offline"}
我有什么:
{"user1":"online"}
{"user2":"offline"}
{"user3":"online"}
如何为此做出正确的 linq 语句?
【问题讨论】:
-
我在一个项目中实现了PaginatedList。我会检查一下,看看它是否适合你。
标签: .net linq entity-framework-core