2012-09-20 89 views
0
Public ReadOnly Property logs() As CloudTableQuery(Of adlog) 
Get 
Return CreateQuery(Of adlog)("adlog").AsTableServiceQuery() 
End Get 
End Property 

我有下面的代碼執行()CloudTableQuery的功能似乎無限

Dim oContext = New kdlib.kdlogs.adlog_context() 
Dim q = From adlogs In oContext.logs Where adlogs.PartitionKey = "xxxxxx" 

會帶回只有1000行

如果我添加.Execute(),因爲我在其他地方見過:

Dim q = From adlogs In oContext.logs.Execute() Where adlogs.PartitionKey = "xxxxxx" 

要求永無止境

我真的不明白。下面

這裏基於全成答案

編輯現在的工作

Dim azt_context As New tableContextGet 
Dim azt_query As CloudTableQuery(Of adlog) 
azt_query = azt_context.CreateQuery(Of adlog)("adlog").Where(Function(e) (e.PartitionKey = "xxx")).AsTableServiceQuery() 
Dim azt_result = azt_query.Execute() 

然後azt_result.ToList

回答

0

第一個查詢將查詢參數發送到存儲服務器,它會送你過濾結果。

您的第二個查詢正試圖從表中提取所有數據,然後將其過濾到內存中。這是因爲oContext.logs.Execute()將立即執行查詢,不帶參數。順便說一句,它可能會完成,但可能需要很長時間。

通常,您需要先設置查詢,然後調用.AsTableServiceQuery(),然後獲取結果。我不太瞭解VB.NET,但是這應該給你一個總體思路:

Public ReadOnly Property logs() As CloudTableQuery(Of adlog) 
Get 
Return CreateQuery(Of adlog)("adlog") 
End Get 
End Property 

... 

Dim oContext = New kdlib.kdlogs.adlog_context() 
Dim q = From adlogs In oContext.logs Where adlogs.PartitionKey = "xxxxxx" 
Dim qQuery = q.AsTableServiceContext() //Do this after setting up parameters 
Dim qResult = q.ToList() //Actually executes the query. 
+0

Execute()在參數之前是鍵,謝謝純邏輯。 –