我想知道哪个用户在群组中发送了更多消息。
public class UserEntity : TableEntity
{
public UserEntity()
{
}
public UserEntity(string chatId, string userId)
: base(chatId, userId)
{
}
public int Name { get; set; }
public int MessagesCount { get; set; }
}
当我收到新消息时,我会增加该用户的 MessagesCount
。一天结束时,我如何知道哪一个的 MessagesCount
最高?
谢谢。
最佳答案
您必须枚举所有实体才能找到MessagesCount
最大的实体。
有关如何设计表格以实现更多场景目标的更多信息,请参阅Azure Storage Table Design Guide .
Update:
I don't know who marked my answer is not useful just now, but it's true that Azure Storage Table service doesn't support server-side sorting. In other words, people have to query ALL the entities from table service and find the minimal/maximal value from client side if the property is not PartitionKey/RowKey, which is what Fei Han's answer actually did. Honestly speaking, such a table scan always means that your table wasn't designed appropriately, that's why I suggested people to read the design guide.
关于c# - 如何获取Azure表中的最高值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45620116/