title: Azure Table Storage Bad Request - Error in query syntax
body: <p>The following used to work.</p>
  
  <pre><code>      public void CreateTableIfMissing()
      {
          var info = new StorageInfo(); // initialized with tablename and connectionstring
          var storageAccount = CloudStorageAccount.Parse(info.ConnectionString);
          var tableClient = storageAccount.CreateCloudTableClient();
          var table = tableClient.GetTableReference(info.TableName);
          try
          {
              table.CreateIfNotExists();
              var batchOperation = new TableBatchOperation();
              var s = DateTime.Now.ToString();
              var entry = new TableEntity("partkey"+s,"rowkey"+s);
              batchOperation.Insert(entry);
              table.ExecuteBatch(batchOperation);
  
          }
          catch (Exception e)
          {
              Console.WriteLine(e);
              throw;
          }
      }
  </code></pre>
  
  <p>Error information is</p>
  
  <pre><code>{Microsoft.WindowsAzure.Storage.StorageException: 
  ErrorCode "InvalidInput"
  Element 0 in the batch returned an unexpected response code.
  StatusMessage:0:Bad Request - Error in query syntax
  </code></pre>
  
  <p>The table is in use for error logging via Serilog with an Azure sync.
  I can see that it is still getting log records if I connect with Azure Storage Explorer.</p>
  
  <p>I have not changed connection strings </p>
  
  <p>[Update]</p>
  
  <p>I am trying a single operation but having trouble</p>
  
  <pre><code>'TableOperation' does not contain a constructor that takes 2 arguments
  Cannot access internal constructor 'TableOperation' here
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/DyTct.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DyTct.png" alt="single op"></a></p>
  
  <p><a href="https://i.stack.imgur.com/5Mfbd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5Mfbd.png" alt="more info"></a></p>
  
  <p>[Update]</p>
  
  <p>If I follow Ivan's advice but omit the ToString("o") parameter the error is</p>
  
  <pre><code>ErrorMessage:The 'PartitionKey' parameter of value 'partkey3/7/2019 8:33:25 PM' is out of range.
  </code></pre>
  
  <p>This makes sense.</p>
  
  <p>I wonder why it ever worked!</p>