dtretyakov/WindowsAzure

Problem querying string fields with single quote in parameter value

Opened this issue · 0 comments

Hi,

In our project, we have the following function:

private CustomerEntity RetrieveCustomer(string partitionKey, string firstName, string lastName)
{
    var customerTable = new TableSet<CustomerEntity>(this.GetCloudTableClient(), "Customers");
    var query = from c in customerTable 
        where c.PartitionKey == partitionKey && c.FirstName == firstName && c.LastName == lastName
        select c;

    return query.FirstOrDefault();
}

When the value of the first or last name contains a single quote, the query sent to Azure will generate a StorageException. Looking at how the framework handles filter parameters, we can see every parameter goes through this manipulation:

givenValue.Replace("'", "''")

Is there a way to enforce that every string we query is converted similarly?

Thanks for your time!