Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure C#v2函数:TableContinuationToken不包含ContinuationToken的定义_C#_Azure - Fatal编程技术网

Azure C#v2函数:TableContinuationToken不包含ContinuationToken的定义

Azure C#v2函数:TableContinuationToken不包含ContinuationToken的定义,c#,azure,C#,Azure,我正在尝试使用Azure v2 C#Function+.NET Core SDK 3.1读取Azure表存储的前十行。但是,我在这行代码中遇到以下错误(token=token.ContinuationToken;): “TableContinuationToken”不包含的定义 “ContinuationToken” 但是,考虑到在这个答案()中,该答案的作者从TableContinuationToken对象检索到ContinuationToken属性,这没有多大意义。下面是我的代码: Stor

我正在尝试使用Azure v2 C#Function+.NET Core SDK 3.1读取Azure表存储的前十行。但是,我在这行代码中遇到以下错误(
token=token.ContinuationToken;
):

“TableContinuationToken”不包含的定义 “ContinuationToken”

但是,考虑到在这个答案()中,该答案的作者从
TableContinuationToken
对象检索到
ContinuationToken
属性,这没有多大意义。下面是我的代码:

StorageCredentials creds = new StorageCredentials(accountName, accountKey);
CloudStorageAccount account = new CloudStorageAccount(creds, useHttps: true);

// Retrieve the role assignments table
CloudTableClient client = account.CreateCloudTableClient();
CloudTable table = client.GetTableReference("OneAuthZRoleAssignments");

// Test out retrieving a small portion from the role assignments table (10 rows)
var tablePortion = new List<RoleAssignment>();
TableContinuationToken token = null;
var rowCount = 0;
do
{
    var queryResult = table.ExecuteQuerySegmentedAsync(new TableQuery<RoleAssignment>(), token);
    tablePortion.AddRange(queryResult.Result);
    token = token.ContinuationToken;
    rowCount++;
} while (rowCount < 10);

// Print out the contents of the table
foreach (RoleAssignment role in tablePortion)
{
    Console.WriteLine(role.Timestamp);
}
StorageCredentials creds=新的StorageCredentials(accountName,accountKey);
CloudStorageAccount=新的CloudStorageAccount(creds,useHttps:true);
//检索角色分配表
CloudTableClient=account.CreateCloudTableClient();
CloudTable=client.GetTableReference(“OneAuthZRoleAssignments”);
//测试从角色分配表中检索一小部分(10行)
var tablepartment=新列表();
TableContinuationToken=空;
var rowCount=0;
做
{
var queryResult=table.ExecuteQuerySegmentedAsync(新TableQuery(),标记);
TableParty.AddRange(queryResult.Result);
token=token.ContinuationToken;
行计数++;
}而(行数<10);
//打印出表格的内容
foreach(表部分中的角色分配角色)
{
Console.WriteLine(role.Timestamp);
}

请更改以下行:

token = token.ContinuationToken;

更新

请尝试以下代码:

do
{
    var queryResult = await table.ExecuteQuerySegmentedAsync(new TableQuery<RoleAssignment>(), token);
    tablePortion.AddRange(queryResult.Result);
    token = queryResult.ContinuationToken;
    rowCount++;
} while (rowCount < 10);
do
{
var queryResult=await table.ExecuteQuerySegmentedAsync(new TableQuery(),token);
TableParty.AddRange(queryResult.Result);
token=queryResult.ContinuationToken;
行计数++;
}而(行数<10);

本质上,您没有等待
异步
操作。

不幸的是,我也遇到了这个错误:任务不包含continuationToken的定义。我是否可能缺少导入?看起来可能是这样,但我不知道它是什么…您使用的是什么版本的存储SDK?没关系…您缺少
wait
:)。我已经更新了我的答案。请试一试。
do
{
    var queryResult = await table.ExecuteQuerySegmentedAsync(new TableQuery<RoleAssignment>(), token);
    tablePortion.AddRange(queryResult.Result);
    token = queryResult.ContinuationToken;
    rowCount++;
} while (rowCount < 10);