I'm attempting to process records that were inserted into Azure Table Storage prior to the addition of a new attribute. The LINQ support is limited and I'm struggling to get this to work.
How would one use LINQ (or another method) to filter an Azure Table to just records missing an attribute for a given entity?
I'm writing it in an Azure Function, and the row count here returns 0, when attempting a default value for the field.
#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
generates a compilation errorString.IsNullOrEmpty(r.Category)
returns that it's not supportedr.Category == null
returns a bad request!r.Category.HasValue
generates a compilation error as it's a stringIf the property did not exist on the entity when it was written to table storage than that column will not exist on the table hence any comparison you make in your query - including the comparison with an empty string - will fail and you will get an empty response.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With