You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
StatisticRecord.Statistics.Value always looks like a value like this 1/1/1970 12:40:57 AM on 1/1/1970
Ironically, StatisticType.Sum seems to work. Below is an example function that illustrates the problem with StatisticType.Maximum. Just pass it a Geodatabase
publicasync Task TestDateMax(Geodatabasegdb){foreach(var t in gdb.GeodatabaseFeatureTables){if(t.LoadStatus != LoadStatus.Loaded){await t.LoadAsync();}vardateFields=newList<Field>();//Get all the date fieldsforeach(var f in t.Fields){if(f.FieldType == FieldType.Date){
dateFields.Add(f);}}//If no date fields or records skip this tableif(dateFields.Count ==0|| t.NumberOfFeatures ==0){continue;}
System.Diagnostics.Debug.WriteLine($"Testing {t.TableName} with {t.NumberOfFeatures} features");varfieldToMax_Loop=newDictionary<Field,DateTimeOffset?>();//Manually (slowly) get the max for each date fieldvarqp=new QueryParameters();varfeatures=await t.QueryFeaturesAsync(qp);foreach( ArcGISFeature feature in features){if(feature.LoadStatus != LoadStatus.Loaded){await feature.LoadAsync();}foreach(var f in dateFields){varvalue=(DateTimeOffset?) feature.GetAttributeValue(f);if(!fieldToMax_Loop.TryGetValue(f,outDateTimeOffset? currentValue)){
fieldToMax_Loop[f]=value;}else{if(value>currentValue){
fieldToMax_Loop[f]=value;}}}}//Now lets's try to use StatisticType.Maximum and log the differences.. HINT they all breakvarfieldToMax_StatisticTypeMaximum=newDictionary<Field,DateTimeOffset?>();intfieldsWrongCount=0;intfieldsOkCount=0;foreach(var f in dateFields){varstatList=newList<StatisticDefinition>();stringstatFieldName="MaxOf"+ f.Name;varsd=new StatisticDefinition(f.Name, StatisticType.Maximum, statFieldName);
statList.Add(sd);varstatParams=new StatisticsQueryParameters(statList);vartableStats=await t.QueryStatisticsAsync(statParams).ConfigureAwait();varstatRecord= tableStats.First();varstatValue=(DateTimeOffset?)statRecord.Statistics[statFieldName];
fieldToMax_StatisticTypeMaximum[f]=statValue;
fieldToMax_Loop.TryGetValue(f,outDateTimeOffset? loopValue);if(loopValue!=null){if(loopValue!=statValue){//SHOULD NEVER GET TO THIS LINE OF CODE---BUT WE DO
System.Diagnostics.Debug.WriteLine($"{t.TableName}.{f.Name} LoopMax={loopValue}, statMax={statValue}");fieldsWrongCount++;}else{fieldsOkCount++;}}}}}
The text was updated successfully, but these errors were encountered:
StatisticRecord.Statistics.Value always looks like a value like this 1/1/1970 12:40:57 AM on 1/1/1970
Ironically, StatisticType.Sum seems to work. Below is an example function that illustrates the problem with StatisticType.Maximum. Just pass it a Geodatabase
The text was updated successfully, but these errors were encountered: