Oliver Weichhold
Oliver Weichhold

Reputation: 10296

Partition Key Question

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();

Upvotes: 2

Views: 250

Answers (1)

dunnry
dunnry

Reputation: 6868

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.

Upvotes: 1

Related Questions