我们如何检索存储在azure表存储中的特殊字符?
我正在使用以下方法从表存储中检索结果:
public static async Task<IList<T>> ExecuteQueryAsync<T>(this CloudTable table, TableQuery<T> query) where T : ITableEntity, new()
{
var items = new List<T>();
TableContinuationToken token = null;
do
{
TableQuerySegment<T> seg = await table.ExecuteQuerySegmentedAsync(query, token);
token = seg.ContinuationToken;
items.AddRange(seg);
} while (token != null);
return items;
}
当数据中包含特殊字符(例如&
)时,它将以&
的形式返回。表存储中的数据示例如下所示:
但是,检索G&P4
时会将其编码为G&P4
。
我们如何检索存储在azure表存储中的特殊字符?
这是查询和一些业务逻辑:
TableQuery<T> treanslationsQuery = new TableQuery<T>().Where(
TableQuery.CombineFilters(
TableQuery.CombineFilters(
TableQuery.GenerateFilterCondition("sourceParty", QueryComparisons.Equal, sourceParty.ToLowerTrim()),
TableOperators.And,
TableQuery.GenerateFilterCondition("destinationParty", QueryComparisons.Equal, destinationParty.ToLowerTrim())
), TableOperators.Or,
TableQuery.CombineFilters(
TableQuery.GenerateFilterCondition("sourceParty", QueryComparisons.Equal, wildcardSourceParty),
TableOperators.And,
TableQuery.GenerateFilterCondition("destinationParty", QueryComparisons.Equal, destinationParty.ToLowerTrim()))
));
var over1000Results = table.ExecuteQueryAsync(treanslationsQuery).Result.Cast<Translation>().ToList();
return over1000Results.Where(x => x.expireAt > DateTime.Now)
.Where(x => x.effectiveAt < DateTime.Now)
.ToList();