2017-11-08 6 views
0

나는 deviceid, timestamp 및 pm1을 저장하는 테이블 저장소를 가지고 있습니다. 특정 장치 ID 및 특정 시간 범위 사이에있는 엔티티에 액세스하기 위해 C#을 사용하려고합니다. 내가 원하는 엔티티를 얻을 수 있었지만이 엔티티에 대한 pm1 판독 값은 올바르지 않은 0입니다. pm1 판독 값은 테이블 저장 영역에 없습니다. 어떻게 해결할 수 있을까요? 내가 원하는 결과 여기C#을 통해 액세스되는 테이블 저장소의 엔터티 속성 값이 0입니다.

[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 

됩니다 : 당신이 반환 pm1con을 볼 수 있습니다 그래서 enter image description here

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

} 

반환 된 결과입니다 : 여기

내 코드입니다 가치가 잘못되었습니다.

+0

문제 해결을 위해 소스 코드의 일부를 공유하십시오. 문제를 설명하기에 설명이 충분하지 않다고 생각합니다. –

+0

@ ZhaoxingLu-Microsoft 질문이 편집되었습니다. 제발 봐봐 –

답변

0

문제는 데이터 유형에 관한 것입니다. float를 pm1con 데이터 형식으로 사용했지만 double을 사용해야합니다.

+0

예, float는 Azure Storage Table에서 지원되지 않습니다. –

+0

십진수를 지원합니까? 이것은 혼란 스럽다. –

+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# 함수에서 사용해야합니다. –