Concatenation of Azure storage table query
-
29. června 2012 7: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
Všechny reakce
-
29. června 2012 14:23
The equals sign is not valid in a query. You need to use the eq operator instead.- Označen jako odpověď Avijit Chatterjee 2. července 2012 4:32
-
2. července 2012 4:33Thanks Brian, query runs fine with eq operator.
Thanks, Avijit Chatterjee
-
4. ledna 2013 11:59Avijit, How do you the eq Operator? I have the same problem. Do you can post your code that works, pls?
-
4. ledna 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.
-
16. ledna 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