【问题标题】:Can't able to get a list of rows in blobstorage tables using C#无法使用 C# 获取 blobstorage 表中的行列表
【发布时间】:2020-10-16 17:23:47
【问题描述】:

我正在尝试通过传递列名和值来返回行列表。代码如下所示

public List<SecuritySchema> GetSecuritySchemaDetailsByProjectId(int id)
    {
        CloudTable cloudTable = GetCloudTable();
        TableQuery<SecuritySchema> securitySchemas = new TableQuery<SecuritySchema>()
                .Where(TableQuery.GenerateFilterCondition(Constants.SecuritySchema.PROJECTID_COLUMN_NAME,
                 QueryComparisons.Equal, id.ToString()));
        var securitySchemaDetail = cloudTable.ExecuteQuery(securitySchemas).ToList();

        return securitySchemaDetail;
    }

但计数显示为 0。但在表中我有 2 行。我在域类中使用 int 作为 ProjectId。

请帮我整理一下。

【问题讨论】:

  • 您的表中有多少个实体(总共)?还有,PROJECTID_COLUMN_NAME属性的数据类型是什么?
  • 我为 PROJECTID_COLUMN_NAME 提供了字符串。我定义了 8 个实体,包括分区键、行键和时间戳,总共 11 个。@GauravMantri-AIS
  • 谢谢。你的表中有多少行?您提到了 2,但不清楚是总行数还是与您的查询匹配的总行数。
  • 目前只有 2 行。但总共有 11 列。 @GauravMantri-AIS
  • 你能仔细检查一下表存储中你的列的类型吗?如果它存储为Int32,那么您必须使用GenerateFilterConditionForInt 方法而不是GenerateFilterCondition

标签: c# .net asp.net-core azure-blob-storage azure-table-storage


【解决方案1】:

只是总结罗曼的评论,以帮助其他有同样问题的人。

仔细检查表存储中列的类型。

如果它存储为Int32,那么您必须使用GenerateFilterConditionForInt 方法而不是GenerateFilterCondition。

GenerateFilterCondition:为字符串值生成一个属性过滤条件字符串。

GenerateFilterConditionForInt:为 Int32 值生成属性过滤条件字符串。

【讨论】:

    猜你喜欢
    • 2015-11-20
    • 2014-10-03
    • 1970-01-01
    • 2011-04-22
    • 1970-01-01
    • 2014-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多