Select to view content in your preferred language

How to Determine Data Type of Attribute (in Query Results)

691
3
08-24-2010 02:52 AM
DavidLowther
Deactivated User
I am executing various queries against FeatureLayers and DynamicMapServiceLayers. My results (QueryEventArgs) include a FeatureSet. Digging into that you end up with a Graphic with Attributes.

My question: How do I know the data type of a given attribute column?

I initially thought I could just do theGraphic.Attributes(colName).GetType.FullName, but I have seen that the object will change from System.Int32 to System.Decimal within a column. This happens when the first value is 2335 and the second is 2335.5.

I've considered hitting the REST service for the layer, but that seems like overkill when I see that the API has a Field class and FieldType enumeration that seem to be purposed with my question in mind. The only trouble is I cannot find where they are used or available.

Thoughts?
0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor
For a FeatureLayer you can investigate the attribute type based on the layer's LayerInfo.Fields.
0 Kudos
dotMorten_esri
Esri Notable Contributor
Prior to ArcGIS Server v10, this fields information was not available in the query result, so there was no way for Silverlight to know if for instance "10" is an integer, double or decimal, and it's JSON Deserializer will parse it as whatever it looks like (in this case integer).
However if you hit an ArcGIS Server 10, you should be seeing consistent data types on the attributes.
0 Kudos
DavidLowther
Deactivated User
Thanks Morten and Jennifer for your responses.

I ended up using the REST API to get this information because I am using a 9.3 AGS.
0 Kudos