2017-11-08 6 views
0

私はdeviceid、timestamp、およびpm1を格納するテーブルストレージを持っています。私は特定のデバイスIDと特定の時間範囲の間にあるエンティティにアクセスするためにC#を使用しようとしています。私が望む実体を得ることができましたが、これらの実体のpm1の読みは正しいものではありません。 pm1の読みは、テーブルの格納には欠けていません。どうすればこの問題を解決できますか?ここでC#でアクセスされるテーブルストレージのエンティティのプロパティ値はゼロです

は私のコードです:ここ

main(): 
    string partitionFilter = TableQuery.GenerateFilterCondition("deviceid", QueryComparisons.Equal, StartEntity.deviceid); 
      string date1 = TableQuery.GenerateFilterConditionForDate("ts", QueryComparisons.GreaterThanOrEqual,starttime); 
      string date2 = TableQuery.GenerateFilterConditionForDate("ts", QueryComparisons.LessThanOrEqual, endtime); 
      string datefilter = TableQuery.CombineFilters(date1, TableOperators.And, date2); 
      string pm1con = TableQuery.GenerateFilterConditionForInt("pm1con", QueryComparisons.GreaterThan, 0); 
      string finalFilter = TableQuery.CombineFilters(partitionFilter,TableOperators.And, datefilter); 
      string extrafilter = TableQuery.CombineFilters(finalFilter, TableOperators.And, pm1con); 
      TableQuery<EventEntity> RangeQueryforEnentEntities = new TableQuery<EventEntity>().Where(extrafilter); 
      TableContinuationToken token = null; 

      do 
      { 
       TableQuerySegment<EventEntity> resultSegment = EventsTable.ExecuteQuerySegmented(RangeQueryforEnentEntities, token); 
       token = resultSegment.ContinuationToken; 

       foreach (EventEntity entity in resultSegment.Results) 
       { 
        EventEntities.Add(entity); 
        log.Info($"C# All the entities in current event: {entity.deviceid}, {entity.ts}, {entity.PM1Con}"); 
       } 

      } while (token != null); 

      return EventEntities; 

public class EventEntity : TableEntity 
{ 
    public EventEntity(string deviceid, DateTime ts, int PM1Con, float TumblingB_threshold, float TumblingB_confidence) 
    { 
     this.PartitionKey = deviceid; 
     this.RowKey = ts.ToLongDateString(); 
    } 

    public EventEntity() { } 

    public string deviceid { get; set; } 

    public DateTime ts { get; set; } 

    public float pm1con { get; set; } 

    public float TumblingB_threshold { get; set; } 

    public float TumblingB_confidence { get; set; } 

} 

は、返された結果である:あなたがリターンpm1conを見ることができるように enter image description here

ここ
[2017-11-08 5:25:59 PM] C# All the entities in current event: HAVEN-0D0E0A-TZ-000115, 2017-10-25 2:42:00 AM, 0 
[2017-11-08 5:25:59 PM] C# All the entities in current event: HAVEN-0D0E0A-TZ-000115, 2017-10-25 2:45:00 AM, 0 
[2017-11-08 5:25:59 PM] C# All the entities in current event: HAVEN-0D0E0A-TZ-000115, 2017-10-25 2:51:00 AM, 0 
[2017-11-08 5:25:59 PM] C# All the entities in current event: HAVEN-0D0E0A-TZ-000115, 2017-10-25 2:54:00 AM, 0 
[2017-11-08 5:25:59 PM] C# All the entities in current event: HAVEN-0D0E0A-TZ-000115, 2017-10-25 2:57:00 AM, 0 
[2017-11-08 5:25:59 PM] C# All the entities in current event: HAVEN-0D0E0A-TZ-000115, 2017-10-25 3:00:00 AM, 0 
[2017-11-08 5:25:59 PM] C# All the entities in current event: HAVEN-0D0E0A-TZ-000115, 2017-10-25 3:03:00 AM, 0 
[2017-11-08 5:25:59 PM] C# All the entities in current event: HAVEN-0D0E0A-TZ-000115, 2017-10-25 3:06:00 AM, 0 
[2017-11-08 5:25:59 PM] C# All the entities in current event: HAVEN-0D0E0A-TZ-000115, 2017-10-25 3:09:00 AM, 0 
[2017-11-08 5:25:59 PM] C# All the entities in current event: HAVEN-0D0E0A-TZ-000115, 2017-10-25 3:12:00 AM, 0 
[2017-11-08 5:25:59 PM] C# All the entities in current event: HAVEN-0D0E0A-TZ-000115, 2017-10-25 3:15:00 AM, 0 
[2017-11-08 5:25:59 PM] C# All the entities in current event: HAVEN-0D0E0A-TZ-000115, 2017-10-25 3:18:00 AM, 0 

私が望む結果であり、値が間違っています。

+0

トラブルシューティングのためにソースコードの一部を共有してください。問題の特定に十分な説明ではないと思います。 –

+0

@ ZhaoxingLu-Microsoft質問が編集されます。どうぞよろしくお願いいたします –

答えて

0

問題はデータ型に関するものです。私はpm1conデータ型としてfloatを使用しましたが、私はdoubleを使うべきです。

+0

はい、Azure Storage Tableではfloatがサポートされていません。 –

+0

10進数をサポートしていますか?これは混乱しています。 –

+0

紛らわしいことではありません。サポートされているすべてのデータ型をここで見つけることができます:https://docs.microsoft.com/en-us/rest/api/storageservices/understanding-the-table-service-data-model –

0

entity.PM1Conの代わりにentity.pm1conを使用します。

テーブルエンティティの変換は大文字と小文字を区別します。

+0

pm1conに変更しましたが、何も変更していません。しかし、 –

+0

に感謝します。ストリーミングアナリティクスでは、フィールド名はPM1Conですが、紺碧のストレージではpm1conを示しています。どちらを私のC#関数で使うべきですか? –

関連する問題