Determine field type
I am trying to determine a field type to help with querying numbers vs strings. In the workflow I am trying to use the GetLayerProperty tool to return the fields without much luck. I can see that it is returning the correct information when I have the debug on. The return information looks like this:
[{"alias":"OBJECTID","dataType":"Int32","displayName":"OBJECTID","focusField":false,"name":"OBJECTID","searchable":false,"visible":false},{"alias":"Shape","dataType":"Object","displayName":"Shape","focusField":false,"name":"Shape","searchable":false,"visible":false},{"alias":"Location","dataType":"String","displayName":"Location","focusField":false,"name":"Location","searchable":true,"visible":true},{"alias":"Sponsored By","dataType":"String","displayName":"Sponsored By","focusField":false,"name":"Sponsors","searchable":true,"visible":true},{"alias":"Bike Tech","dataType":"String","displayName":"Bike Tech","focusField":false,"name":"BikeTech","searchable":true,"visible":true},{"alias":"Season","dataType":"String","displayName":"Season","focusField":false,"name":"Season","searchable":true,"visible":true},{"alias":"Year","dataType":"String","displayName":"Year","focusField":false,"name":"Year","searchable":true,"visible":true},{"alias":"Time Of Day","dataType":"String","displayName":"Time Of Day","focusField":false,"name":"TimeOfDay","searchable":false,"visible":false},{"alias":"ID","dataType":"String","displayName":"ID","focusField":false,"name":"ID","searchable":true,"visible":true}]
The problem is capturing this in a variable so I can use it. I have tried several different variable types without much luck. The most luck I have had was to use an array of ESRI.ArcGIS.Client.Field to capture the returned values. When I look at the array it his the correct length but everything in it is empty.
Has anyone found the correct way to accomplish or am I on the wrong track totally.
-
Marcus,
Wonder how you can get the json string of the "Fields" property of the Layer from GetLayerProperty. It is the Collection<Field> where Field is the Gcx Field object which is not serializable object.
However, if you can have the Json presentation of the Fields, you can convert to the Dictionary using JsonToDictionary to get the field type you are looking for. But I don't know how you get the Json string you wrote on your post.
You may try to using QueryTask to get one Feature from the Layer, and loop through the Attributes to get the field type. That is one way to do.
Munhwan
0
Please sign in to leave a comment.
Comments
1 comment