0

我正在查看 Microsoft 提供的示例“完成时处理任务”并将该 TPL 示例调整为 Azure 存储。

我遇到的问题在下面标记了变量domainData在编译器中报告错误的位置:(Unknown method Select(?) of TableQuerySegment<DynamicTableEntity> 已删除完全限定的命名空间)

我也收到以下错误DynamicTableEntity domainData \n\r Unknown type of variable domainData

      /// if you have the necessary references the following most likely should compile and give you same error

            CloudStorageAccount acct = CloudStorageAccount.DevelopmentStorageAccount;

            CloudTableClient client = acct.CreateCloudTableClient();
            CloudTable tableSymmetricKeys = client.GetTableReference("SymmetricKeys5");

            TableContinuationToken token = new TableContinuationToken() { };
            TableRequestOptions opt = new TableRequestOptions() { };
            OperationContext ctx = new OperationContext() { ClientRequestID = "ID" };
            CancellationToken cancelToken = new CancellationToken();

            List<Task> taskList = new List<Task>();

            var task2 = tableSymmetricKeys.CreateIfNotExistsAsync(cancelToken);
            task2.Wait(cancelToken);


            int depth = 3;
            while (true)
            {
                Task<TableQuerySegment<DynamicTableEntity>> task3 = tableSymmetricKeys.ExecuteQuerySegmentedAsync(query, token, opt, ctx, cancelToken);

                // Run the method
                task3.Wait();

                 Console.WriteLine("Records retrieved in this attempt = " + task3.Result.Count());// + " | Total records retrieved = " + state.TotalEntitiesRetrieved);



        // HELP! This is where I'm doing something the compiler doesn't like
        //
                IEnumerable<Task<int>> getTrustDataQuery =
                              from domainData in task3.Result select QueryPartnerForData(domainData, "yea, search for this.", client, cancelToken);

                // Prepare for next iteration or quit
                if (token == null)
                {
                    break;
                }
                else
                {
                    token = task3.Result.ContinuationToken;

                    // todo: persist token  token.WriteXml()
                }
            }




    //....

  private static object QueryPartnerForData(DynamicTableEntity domainData, string p, CloudTableClient client, CancellationToken cancelToken)
    {
        throw new NotImplementedException();
    }
4

1 回答 1

0

您的代码缺少查询。为了测试代码,我创建了以下查询:

TableQuery<DynamicTableEntity> query = new TableQuery<DynamicTableEntity>()
    .Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "temp"));

我还添加了QueryPartnerForData不执行任何操作的方法(仅返回 null)并且一切正常。所以也许这是QueryPartnerForData方法的问题?找到实际错误的最佳方法是在这里和那里设置断点。

StackOverflowException 通常意味着您陷入了无限循环。通过断点运行几次,看看你的代码卡在哪里。会不会是QueryPartnerForData调用了另一个方法,而另一个方法又调用QueryPartnerForData了?

于 2012-11-26T06:45:44.963 回答