locked
Table Storage query does not populate all fields RRS feed

  • Question

  • I'm trying to query a TableStorage with the following method:

     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;
            }
        }

    invoking it as follows 

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

    TelemetryTS is declared as follows:

    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 string UTC { get; set; }
            public double VA { get; set; }
            public double VIn { get; set; }
            public double VOut { get; set; }
            public double Var { get; set; }
            public double VarSCnt { get; set; }
            public double Varh { get; set; }
            public double W { get; set; }
            public double Wh { get; set; }
            public Int64 WsCnt { get; set; }
            public double cIn { get; set; }
            public double cOut { get; set; }
            public double kVar { get; set; }
            public double kVarh { get; set; }
            public double kW { get; set; }
            public double kWh { get; set; }
            public Int64 tSlot { get; set; }
            public Int64 PartitionId { get; set; }
            public Int64 Sampling { get; set; }
            public string mts { get; set; }
            public Int64 nDips { get; set; }
            public Int64 nSwells { get; set; }
            public Int64 tDips { get; set; }
            public Int64 tSwells { get; set; }
    
            public string deviceId { 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; }
    
        }

    The number of records returned is correct, but in the individual records not all fields are populated as shown in StorageExplorer. For example DateTime fields are not retrieved correctly.

    What could be the problem?

    Thanks for the help

    Simone



    Simone Spagna Consulente Informatico

    Tuesday, January 14, 2020 6:09 PM

Answers

All replies

  • Firstly, apologies for the delay in responding here and any inconvenience this issue may have caused.  What's the meaning of "For example DateTime fields are not retrieved correctly."? Not retrieved or retrieved a incorrect value


    Thursday, January 16, 2020 6:31 AM
  • Thanks. I solcved the issue.

    Simone Spagna Consulente Informatico

    Thursday, January 16, 2020 6:23 PM
  • Glad to hear that issue got fixed. It will be highly appreciated if you share the troubleshooting steps   which helped you, this would certainly benefit other community members who is reading this thread!

    Friday, January 17, 2020 9:06 AM