如何 select 记录 Azure 存储 Table 中缺少的字段?

How to select records where field is missing from an Azure Storage Table?

我正在尝试处理在添加新属性之前插入到 Azure Table 存储中的记录。 LINQ support is limited,我正在努力让它发挥作用。

如何使用 LINQ(或其他方法)过滤 Azure Table 以仅记录缺少给定实体的属性?

示例代码

我在 Azure 函数中编写它,这里的行数 returns 0,在尝试为该字段设置默认值时。

#r "Microsoft.WindowsAzure.Storage"

using System.Net;
using Microsoft.WindowsAzure.Storage.Table;

public static HttpResponseMessage Run(HttpRequestMessage req, IQueryable<ts_webhit> inTable, TraceWriter log)
{
    IEnumerable<ts_webhit> recs = (from r in inTable
                                   where "2016-11-21 12:45" == r.PartitionKey
                                   &&    ""                 == r.Category  //The filter I need to run
                                   select r);
    log.Info($"{recs.Count()}");
    return req.CreateResponse(HttpStatusCode.OK, recs.ToList());
}

public class ts_webhit : TableEntity
{

    public string Category { get; set; } = ""; //Attempting a default value

}

一些无效的候选过滤器

如果 属性 在写入 table 存储时实体上不存在,那么 table 上将不存在该列,因此您在查询中进行的任何比较- 包括与空字符串的比较 - 将失败,您将得到一个空响应。