Concatenation of Azure storage table query

Traitée Concatenation of Azure storage table query

  • vendredi 29 juin 2012 07:17
     
     

    Hi,

    I want to query a result from Azure strorage. Please find below scenario:

    1. I have a method having a general query and custom query( as parameter) append to this

          constructedQuery = String.Format("Timestamp lt datetime'2012-06-29T06:53:39Z' and {0}", tableQuery);

    Then I execute the query.

    My custom query is "ServerEndpoint='10.146.30.208:9001' and ClientIP='10.146.30.211'" which comes as paramter to the above method.

    The final query runs fine in Azure Storage explorer but throws error while run from C# code. Can anyone help me on this. Below in the final query fomed and the exception. it's urgent.

    Info   [06/29-07:03:39.802]  Quering table SLBTCPUDPServerData with constructed query Timestamp gt datetime'2012-06-29T07:03:39Z' and Timestamp lt datetime'2012-06-29T06:53:39Z' and ServerEndpoint='10.146.30.208:9001' and ClientIP='10.146.3
    0.211'
    [06/29/12 07:03:39.943] Avi: After query execution
    Info   [06/29-07:03:39.943]  Avi: After query execution
    [06/29/12 07:04:04.420] Avi: In catch
    Info   [06/29-07:04:04.420]  Avi: In catch
    [06/29/12 07:04:04.420] To query UDPTables For Status failed due to System.Data.Services.Client.DataServiceQueryExceptio
    n: An error occurred while processing this request. ---> System.Data.Services.Client.DataServiceClientException: <
    ?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
      <code>InvalidInput</code>
      <message xml:lang="en-US">One of the request inputs is not valid.
    RequestId:13159490-e1b7-4af5-a270-4d7b0f55c7bb
    Time:2012-06-29T07:04:04.3552753Z</message>
    </error>
       at System.Data.Services.Client.BaseAsyncResult.EndExecute[T](Object source, String method, IAsyncResult asyncResult)
       at System.Data.Services.Client.QueryResult.EndExecute[TElement](Object source, IAsyncResult asyncResult)
       --- End of inner exception stack trace ---
       at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.get_Result()
       at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.ExecuteAndWait()
       at Microsoft.WindowsAzure.StorageClient.CommonUtils.<LazyEnumerateSegmented>d__0`1.MoveNext()
       at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source)
       at Microsoft.Cloudnet.Slb.PerfTests.LibraryTests.QueryUDPTablesForStatus()
    Error   [06/29-07:04:04.420]  To query UDPTables For Status failed due to System.Data.Services.Client.DataServiceQueryEx
    ception: An error occurred while processing this request. ---> System.Data.Services.Client.DataServiceClientException: <
    ?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
      <code>InvalidInput</code>
      <message xml:lang="en-US">One of the request inputs is not valid.
    RequestId:13159490-e1b7-4af5-a270-4d7b0f55c7bb
    Time:2012-06-29T07:04:04.3552753Z</message>
    </error>
       at System.Data.Services.Client.BaseAsyncResult.EndExecute[T](Object source, String method, IAsyncResult asyncResult)
       at System.Data.Services.Client.QueryResult.EndExecute[TElement](Object source, IAsyncResult asyncResult)
       --- End of inner exception stack trace ---
       at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.get_Result()
       at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.ExecuteAndWait()
       at Microsoft.WindowsAzure.StorageClient.CommonUtils.<LazyEnumerateSegmented>d__0`1.MoveNext()
       at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source)
       at Microsoft.Cloudnet.Slb.PerfTests.LibraryTests.QueryUDPTablesForStatus()


    Thanks, Avijit Chatterjee

Toutes les réponses

  • vendredi 29 juin 2012 14:23
     
     Traitée
    The equals sign is not valid in a query. You need to use the eq operator instead. 
  • lundi 2 juillet 2012 04:33
     
     
    Thanks Brian, query runs fine with eq operator.

    Thanks, Avijit Chatterjee

  • vendredi 4 janvier 2013 11:59
     
     
    Avijit, How do you the eq Operator? I have the same problem. Do you can post your code that works, pls?
  • vendredi 4 janvier 2013 12:27
     
     

    For: ServerEndpoint='10.146.30.208:9001' and ClientIP='10.146.30.211'

    You will do something like:

    ServerEndpoint eq '10.146.30.208:9001' and ClientIP eq '10.146.30.211'

    Hope this helps.

  • mercredi 16 janvier 2013 14:21
     
     

    Firstly sorry guys, I was out of sync and could not reply.

    Anyhow, what you need to do is exactly what Gaurav replied. Below example.

    SeerverEndPoint eq '10.146.30.208:9001' and ClientIP eq '10.146.30.211" insteaf of SeerverEndPoint = '10.146.30.208:9001' and ClientIP = '10.146.30.211

    Basically, just replace '=' with 'eq'


    Thanks, Avijit Chatterjee