无法使用 C# 获取 blobstorage 表中的行列表
Can't able to get a list of rows in blobstorage tables using C#
我正在尝试通过传递列名和值来 return 行列表。代码如下
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。但在 table 中我有 2 行。我在域 class.
中使用 int 作为 ProjectId
请帮我整理一下。
简单总结罗曼的评论回复以帮助有同样问题的人。
仔细检查 table 存储中的列类型。
如果它存储为 Int32
那么你必须使用 GenerateFilterConditionForInt
方法而不是 GenerateFilterCondition
。
GenerateFilterCondition
:为字符串值.
生成属性过滤条件字符串
GenerateFilterConditionForInt
:为一个 Int32 值
.生成一个属性过滤条件字符串
我正在尝试通过传递列名和值来 return 行列表。代码如下
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。但在 table 中我有 2 行。我在域 class.
中使用 int 作为 ProjectId请帮我整理一下。
简单总结罗曼的评论回复以帮助有同样问题的人。
仔细检查 table 存储中的列类型。
如果它存储为 Int32
那么你必须使用 GenerateFilterConditionForInt
方法而不是 GenerateFilterCondition
。
GenerateFilterCondition
:为字符串值.
GenerateFilterConditionForInt
:为一个 Int32 值