首页 > 解决方案 > 无法使用 C# 获取 blobstorage 表中的行列表

问题描述

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

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。

请帮我整理一下。

标签: c#.netasp.net-coreazure-blob-storageazure-table-storage

解决方案


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

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

如果它存储为 anInt32那么你必须使用GenerateFilterConditionForInt方法而不是GenerateFilterCondition.

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

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


推荐阅读