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

标签 c# azure azure-table-storage

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

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/

相关文章:

C# 和 Microsoft Speech.Recognition 和 Speech.Synthesis

c# - 如何在 C#/.NET 中找到本地计算机的 FQDN?

c# - 如何在 C# 中等于 2 个日期变量

azure - 如何使用私有(private)Azure容器注册表创建Azure APP服务?

Azure 存储 - 处理跨分区更新

c# - 通过 TCP 传输程序集

c# - 使用 Github Actions 将多项目 ASP.NET Core Web 应用部署到 Azure 应用服务

azure - 有没有办法通过 Windows Azure 上的 Terraform 以 root 用户身份远程执行 shell 脚本

rest - 访问 Azure 表实体

azure - windows azure 表存储,如何启用保持事件状态