针对Azure表存储创建LINQ查询时出错

针对Azure表存储创建LINQ查询时出错,linq,.net-core,azure-table-storage,Linq,.net Core,Azure Table Storage,我正在从.NET CORE 3.1控制台应用程序访问表存储 我正在使用最新(此时)的PM microsoft.azure.cosmos.table\1.0.8\ 这反过来又使用了 Microsoft.Azure.DocumentDB.Core\2.11.2 表上的许多操作都可以正常工作,但我在创建LINQ查询时遇到了一个错误 这是生成错误的行,空引用异常 有人能帮我解决这个问题吗 官方文档很差,我没有找到任何完整的示例来演示如何进行LINQ查询,上面只有一个类似我的片段在我的应用程序中不起作用。

我正在从.NET CORE 3.1控制台应用程序访问表存储

我正在使用最新(此时)的PM

microsoft.azure.cosmos.table\1.0.8\

这反过来又使用了

Microsoft.Azure.DocumentDB.Core\2.11.2

表上的许多操作都可以正常工作,但我在创建LINQ查询时遇到了一个错误

这是生成错误的行,空引用异常

有人能帮我解决这个问题吗

官方文档很差,我没有找到任何完整的示例来演示如何进行LINQ查询,上面只有一个类似我的片段在我的应用程序中不起作用。也许这是版本控制问题,他们使用了以前版本的.NET,但我希望它能与core 3.1一起使用


非常感谢

我能够重现这个问题。问题的出现是因为
TableQuery
Provider
属性为空(不确定原因)

以下是您可以使用的解决方法:

        StorageCredentials credentials = new StorageCredentials("<account-name>", "<account-key>");
        CloudTable table = new CloudTable(new Uri("https://<account-name>.table.core.windows.net/<table-name>"),
            credentials);
        var tableQuery = table.CreateQuery<DocEntity>().Where(r => r.PartitionKey == "somevalue");
StorageCredentials-credentials=newstoragecredentials(“,”);
CloudTable=新的CloudTable(新的Uri(“https://.table.core.windows.net/"),
证书);
var tableQuery=table.CreateQuery()。其中(r=>r.PartitionKey==“somevalue”);

而且您不应该得到错误。

谢谢,我想即使在创建阶段,查询也需要知道引用了哪个表(不仅仅是实体),并且在调用表的createquery方法时,它会获取这些信息。我在使用table方法时,executequery认为这是您需要提供表引用的地方,但我错了。
     var myquery = new TableQuery<DocEntity>()
        .Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "doc_manager_test_client"));
  public class DocEntity : TableEntity {
     public DocEntity() {
     }

     public DocEntity(string doc_manager_id, string doc_id) {
        PartitionKey = doc_manager_id;
        RowKey = doc_id;
     }

     public string DocName { get; set; }
     public string DocCategory { get; set; }
     public Int64 DocSize { get; set; }
  }
        StorageCredentials credentials = new StorageCredentials("<account-name>", "<account-key>");
        CloudTable table = new CloudTable(new Uri("https://<account-name>.table.core.windows.net/<table-name>"),
            credentials);
        var tableQuery = table.CreateQuery<DocEntity>().Where(r => r.PartitionKey == "somevalue");