[mapguide-users] OSGeo.MapGuide.MgNullPropertyValueException

Mamoon mamoonurrasheed at gmail.com
Wed Nov 3 07:56:09 EDT 2010


Hi All,

I am getting exception(OSGeo.MapGuide.MgNullPropertyValueException) when try
to read null value of the property of the feature. I try to handle this
exception but i think this may be MapGuide known issue. Can any body tell me
exact solution or work around. My code is as fellow.

 //Get feature using query.
            MgFeatureReader FeatureReader =
baseLayer.SelectFeatures(queryOptions);
                        

            while (FeatureReader.ReadNext())
            {
                for (int j = 0; j <= FeatureReader.GetPropertyCount() - 1;
j++)
                {                                      
                        Object PropertyValue =
GetPropertyValue(FeatureReader,    FeatureReader.GetPropertyName(j));
              
                              }
            }

 private Object GetPropertyValue(MgFeatureReader FeatureReader, String
PropertyName)
    {
        Object PropertyValue = true;
        //Response.Write(FeatureReader.GetPropertyType(PropertyName));
        switch (FeatureReader.GetPropertyType(PropertyName))
        {
            
            case (0):
                PropertyValue = MgPropertyType.Null;
                break;
            case (1):
                PropertyValue = FeatureReader.GetBoolean(PropertyName);                
                break;
            case (2):
                PropertyValue = FeatureReader.GetByte(PropertyName);
                break;
            case (3):
                PropertyValue = FeatureReader.GetDateTime(PropertyName);
                break;
            case (4):
                PropertyValue = FeatureReader.GetSingle(PropertyName);
                break;
            case (5):
                PropertyValue = FeatureReader.GetDouble(PropertyName);
                break;
            case (6):
                PropertyValue = FeatureReader.GetInt16(PropertyName);
                break;
            case (7):
                PropertyValue = FeatureReader.GetInt32(PropertyName);
                break;
            case (8):
                PropertyValue = FeatureReader.GetInt64(PropertyName);
                break;
            case (9):
                PropertyValue = FeatureReader.GetString(PropertyName);
                break;
            case (10):
                PropertyValue = FeatureReader.GetBLOB(PropertyName);
                break;
            case (11):
                PropertyValue = FeatureReader.GetCLOB(PropertyName);
                break;
            case (12):                
                //PropertyValue = MgPropertyType.Feature();
                break;
            case (13):
                PropertyValue = FeatureReader.GetGeometry(PropertyName);                
                break;
            case (14):
                PropertyValue = FeatureReader.GetRaster(PropertyName);                
                break;
        }

        return PropertyValue;
    }

when control goes in any case and find null value in db, its thrown
exception (OSGeo.MapGuide.MgNullPropertyValueException).

I try to handle this exception with null or system.DBNull but i am surprised
its not going to check the following condition and thrown exception.

if (FeatureReader.GetString(PropertyName) != system.DBNull.Value)
{
PropertyValue = FeatureReader.GetSingle(PropertyName);
}
-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/OSGeo-MapGuide-MgNullPropertyValueException-tp5700982p5700982.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list