表存储查询不会填充所有字段

时间:2020-01-14 11:37:30

标签: c# azure-table-storage

我正在尝试使用以下方法查询TableStorage:

    public async Task<List<T>> RetrieveEntityAsync<T>(string deviceId) where T : TableEntity, new()
    {
        try
        {
            TableQuery<T> DataTableQuery = new TableQuery<T>();
            if (!string.IsNullOrEmpty(deviceId))
            {
               var filter = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, deviceId);
               DataTableQuery = new TableQuery<T>().Where(filter);
            }

            var l = new List<T>();
            TableContinuationToken continuationToken = null;
            do
            {
                var queryResponse = await table.ExecuteQuerySegmentedAsync(DataTableQuery, continuationToken);
                continuationToken = queryResponse.ContinuationToken;
                l.AddRange(queryResponse.Results);
            }
            while (continuationToken != null);
            return l;
        }
        catch (Exception ExceptionObj)
        {
            throw ExceptionObj;
        }
    }

按如下方式调用它:

    List<TelemetryTS> elements = await tabeManager.RetrieveEntityAsync<TelemetryTS>(dto.DeviceIdorId);

TelemetryTS声明如下:

public class TelemetryTS : TableEntity
{

    public TelemetryTS() { }

    public TelemetryTS(string partitionKey, string rowKey)
    {
        this.PartitionKey = partitionKey;
        this.RowKey = rowKey;
    }


    public double AIn { get; set; }
    public double AOut { get; set; }
    public double CosPhi { get; set; }
    public double H { get; set; }
    public string L { get; set; }
    public DateTime MeterTS { get; set; }
    public Int64 PartitionId { get; set; }
    public Int64 Sampling { get; set; }
    public Int64 UTC { get; set; }
    public double VA { get; set; }
    public double VIn { get; set; }
    public double VOut { get; set; }
    public double Var { get; set; }
    public Int64 VarSCnt { get; set; }
    public double Varh { get; set; }
    public double W { get; set; }
    public Int64 WSCnt { get; set; }
    public double Wh { get; set; }
    public double cIn { get; set; }
    public double cOut { get; set; }
    public string deviceId { get; set; }
    public double kVar { get; set; }
    public double kVarH { get; set; }
    public double kW { get; set; }
    public double kWh { get; set; }
    public string mts { get; set; }
    public Int64 nDips { get; set; }
    public Int64 nSwells { get; set; }
    public Int64 tDips { get; set; }
    public Int64 tSlot { get; set; }
    public Int64 tSwells { get; set; }

    public double MaxPotenzaAttiva { get; set; }
    public double MaxTensioneIngresso { get; set; }
    public double MaxPotenzaReattiva { get; set; }
    public double MaxCorrenteIngresso { get; set; }
    public double AvgPotenzaAttiva { get; set; }
    public double AvgTensioneIngresso { get; set; }
    public double AvgPotenzaReattiva { get; set; }
    public double AvgCorrenteIngresso { get; set; }

    public double WhConsumoUltimoGiorno { get; set; }
    public double WhPercRispUltimoGiorno { get; set; }
    public double WhConsumoUltimaSettimana { get; set; }
    public double WhPercRispUltimaSettimana { get; set; }
    public double WhConsumoUltimoMese { get; set; }
    public double WhPercRispUltimoMese { get; set; }

    public double AvgRispDaEfficenzaUltimoGiorno { get; set; }
    public double AvgRispDaEfficienzaUltimaSettimana { get; set; }
    public double AvgRispDaEfficienzaUltimoMese { get; set; }

    public string IoTHubError { get; set; }

    public int severity { get; set; }

}

返回的记录数是正确的,但是在单个记录中,并非所有字段都被填充,如StorageExplorer中所示。例如,DateTime字段未正确检索。

可能是什么问题?

感谢您的帮助

0 个答案:

没有答案
相关问题