linq - 分区键问题

标签 linq azure azure-table-storage

让我这样定义我的实体:

public class User : TableServiceEntity
{
    /// <summary>Unique Id (Row Key)</summary>
    public string Id
    {
        get { return RowKey; }
        set { RowKey = value; }
    }

    /// <summary>Gets or sets the username (Partition Key)</summary>
    public string Username
    {
        get { return PartitionKey; }
        set { PartitionKey = value; }
    } 
}

以下 Linq 查询是否会使用分区键?

var ctx = ServiceLocator.Get<UserDataServiceContext>();
return ctx.Users.Where(x => x.Username == Username).FirstOrDefault();

最佳答案

很确定不会。不过,您可以使用 Fiddler 来验证这一点。如果您没有在线路上看到带有 PartitionKey 和 RowKey 的 $filter,那么您就没有通过它们进行查询(这可能很糟糕)。我相信您将在网络上拥有一个具有 4 个属性(PK、RK、Id 和用户名)的实体,并且您将查询的属性不会被索引。

关于linq - 分区键问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6264170/

相关文章:

c# - join 子句中的表达式之一的类型不正确

c# - 将 IQueryable 类型转换为 Linq to Entities 中的接口(interface)

Azure:将同一域中的单独 Web API 项目发布到另一个 Web 应用程序

java - Azure 存储中的删除批量操作

azure - 无法在 DynamicTableEntity(Azure 表)中使用 "as"关键字

LINQ 按问题分组

c# - 使用 where 获取从最后一个开始的所有其他数字

azure - 在 azure git 部署中包含 TypeScript 文件

azure - MS Service Fabric 安装错误

azure - Windows Azure 表 - 行数?