开发者

Partition Key Question

开发者 https://www.devze.com 2023-03-10 18:39 出处:网络
Let\'s I define my entity like this: public class User : TableServiceEntity { /// <summary>Unique Id (Row Key)</summary>

Let's I define my entity like this:

public class User : TableServiceEntity
{
    /// <summary>Unique Id (Row Key)</summary>
    public string Id
    {
        get { return RowKey; }
      开发者_JAVA技巧  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();


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消