1

我使用WindowsAzure.Storage 9.1.1nuget 包,当我运行时:

var table = GetTableReference(vehicleStatusTableName);
var condition = TableQuery.CombineFilters(
            TableQuery.GenerateFilterCondition(partitionKey, QueryComparisons.Equal, vehicleId.ToString()),
            TableOperators.And,
            TableQuery.GenerateFilterCondition(rowKey, QueryComparisons.Equal, string.Empty));

var query = table.CreateQuery<VehicleStatusEntity>().Where(condition);

它抛出异常:

通过 CloudTable.CreateQuery() 创建的查询可能无法调用流利的方法

我想我以前可以这样做,但现在我不能。怎么了,为什么我会收到这个错误?

4

1 回答 1

0

对于您的查询,您应该使用这行代码:

  var query =new TableQuery<CustomerEntity>().Where(condition);

示例演示如下:

  CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
  CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
  CloudTable table = tableClient.GetTableReference("humans");

  var condition = TableQuery.CombineFilters(
                TableQuery.GenerateFilterCondition("PartitionKey",QueryComparisons.Equal, "Harp222"),
                TableOperators.And,
                TableQuery.GenerateFilterCondition("RowKey",QueryComparisons.Equal, "Walter222")
                );

   var query =new TableQuery<CustomerEntity>().Where(condition);

   foreach (CustomerEntity entity in table.ExecuteQuery(query))
   {
      Console.WriteLine("{0}, {1}\t{2}\t{3}", entity.PartitionKey, entity.RowKey,
                        entity.Email, entity.PhoneNumber);
   }

测试结果如下: 在此处输入图像描述

WindowsAzure.Storage 9.1.1nuget包截图: 在此处输入图像描述

于 2018-10-11T03:08:20.557 回答