分区键问题
让我们这样定义我的实体:
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();
Let's I define my entity like this:
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; }
}
}
will the following Linq query use the partition key or not?
var ctx = ServiceLocator.Get<UserDataServiceContext>();
return ctx.Users.Where(x => x.Username == Username).FirstOrDefault();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
很肯定不会。不过,您可以使用 Fiddler 来验证这一点。如果您没有在线路上看到带有 PartitionKey 和 RowKey 的 $filter,那么您就没有通过它们进行查询(这可能很糟糕)。我相信您将在网络上拥有一个具有 4 个属性(PK、RK、Id 和用户名)的实体,并且您将查询的属性不会被索引。
Pretty sure it will not. You can verify this with Fiddler however. If you do not see a $filter on the wire with PartitionKey and RowKey in it, then you are not querying by them (which is probably bad). I believe what you will have on the wire is an entity that has 4 properties (PK, RK, Id, and Username) and the properties that you will be querying on will not be indexed.