[英]How to select records where field is missing from an Azure Storage Table?
我正在尝试处理在添加新属性之前插入 Azure 表存储的记录。 LINQ 支持有限,我正在努力让它发挥作用。
如何使用 LINQ(或其他方法)过滤 Azure 表以仅记录缺少给定实体的属性?
我在 Azure 函数中编写它,当尝试为该字段设置默认值时,此处的行数返回 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
}
r.Category is nothing
产生编译错误String.IsNullOrEmpty(r.Category)
返回它不受支持r.Category == null
返回错误的请求!r.Category.HasValue
生成一个编译错误,因为它是一个字符串如果该属性在写入表存储时实体上不存在,则该列将不存在于表中,因此您在查询中进行的任何比较 - 包括与空字符串的比较 - 都将失败,您将得到一个空回复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.