Skip to content

Problem querying string fields with single quote in parameter value #46

@uberfrank

Description

@uberfrank

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!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions