gpt4 book ai didi

c# - 如何获取Azure表中的最高值

转载 作者:行者123 更新时间:2023-12-03 04:42:56 26 4
gpt4 key购买 nike

我想知道哪个用户在群组中发送了更多消息。

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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com