dtretyakov / WindowsAzure

.NET library aimed at managing and querying entities from Windows Azure Storage. It can be used as LINQ to Azure Tables.
MIT License
64 stars 27 forks source link

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

Open uberfrank opened 8 years ago

uberfrank commented 8 years ago

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!