How to get propertytypes of items in featureclass

3 messages Options
Embed this post
Permalink
Gunter Becker

How to get propertytypes of items in featureclass

Reply Threaded More More options
Print post
Permalink
Hi,

I would like to get all the propertytypes of the propertyitems in a feature class. What is the best way to do this.

I already tried this:

MgClassDefinition classDef = _featureService.GetClassDefinition(featureSource, schema, featureClass);

MgPropertyDefinitionCollection propertiesDef = classDef.GetProperties();
MgPropertyDefinition propDef = propertiesDef.GetItem(0); // just request one index for test
short propType = propDef.GetPropertyType();

But propType always seems to have the value 100 (except GeometryColumn: 102). I would except that this propertytype is of type MgPropertyType which should return the right type. It is the same like in thread
Managed MgPropertyDefinition.GetPropertyType - broken?
But I can't figure out what I'm doing wrong.

So what other solutions are there to get the right proprtytypes?

Thanks, Gunter
Gunter Becker

Re: How to get propertytypes of items in featureclass

Reply Threaded More More options
Print post
Permalink
OK,

after hours of searching and posting my problem I got at last the idea to look in the Web API and found the answer to my question. Wow!

The value 100 meens that the propertytype is of type "MgDataPropertyDefinition" (102 - "MgGeometricPropertyDefinition"). So I just have to cast it in the right type and then use the "DataType" property of this class:

short dataType = ((MgDataPropertyDefinition)propDef).DataType;

Sorry for making trouble,
Gunter

Gunter Becker wrote:
Hi,

I would like to get all the propertytypes of the propertyitems in a feature class. What is the best way to do this.

I already tried this:

MgClassDefinition classDef = _featureService.GetClassDefinition(featureSource, schema, featureClass);

MgPropertyDefinitionCollection propertiesDef = classDef.GetProperties();
MgPropertyDefinition propDef = propertiesDef.GetItem(0); // just request one index for test
short propType = propDef.GetPropertyType();

But propType always seems to have the value 100 (except GeometryColumn: 102). I would except that this propertytype is of type MgPropertyType which should return the right type. It is the same like in thread
Managed MgPropertyDefinition.GetPropertyType - broken?
But I can't figure out what I'm doing wrong.

So what other solutions are there to get the right proprtytypes?

Thanks, Gunter
Gunter Becker

Re: How to get propertytypes of items in featureclass

Reply Threaded More More options
Print post
Permalink
Sorry,

return value must be of type int

int dataType = ((MgDataPropertyDefinition)propDef).DataType;


Gunter Becker wrote:
OK,

after hours of searching and posting my problem I got at last the idea to look in the Web API and found the answer to my question. Wow!

The value 100 meens that the propertytype is of type "MgDataPropertyDefinition" (102 - "MgGeometricPropertyDefinition"). So I just have to cast it in the right type and then use the "DataType" property of this class:

short dataType = ((MgDataPropertyDefinition)propDef).DataType;

Sorry for making trouble,
Gunter

Gunter Becker wrote:
Hi,

I would like to get all the propertytypes of the propertyitems in a feature class. What is the best way to do this.

I already tried this:

MgClassDefinition classDef = _featureService.GetClassDefinition(featureSource, schema, featureClass);

MgPropertyDefinitionCollection propertiesDef = classDef.GetProperties();
MgPropertyDefinition propDef = propertiesDef.GetItem(0); // just request one index for test
short propType = propDef.GetPropertyType();

But propType always seems to have the value 100 (except GeometryColumn: 102). I would except that this propertytype is of type MgPropertyType which should return the right type. It is the same like in thread
Managed MgPropertyDefinition.GetPropertyType - broken?
But I can't figure out what I'm doing wrong.

So what other solutions are there to get the right proprtytypes?

Thanks, Gunter