Type conversions

The built-in VB functions for data type conversions (CStr, CDate, CInt, etc.) are sensitive to the regional settings for the application or local machine, and therefore should not be used for type conversions in IDO extension class methods.

The Mongoose framework stores all property values internally as strings regardless of their data type. In the framework, this is also true for values stored in components, variables and IDO collections. The internal string format is culture independent so the built-in string conversion functions might not work, or might work inconsistently depending on the data or the current culture settings. The internal formatted string value is always available, but when accessing numeric, date or Guid property values programmatically, you should use the APIs provided by the framework that will convert the values from internal string format to the proper “strong” data types.

IDORequest/Response Property Values (IDOProtocol classes)

Property values in IDO Request and Response classes are represented using the Mongoose.IDO.Protocol.IDOValueType class, or a class that inherits from this class.

This example accesses properties in a LoadCollectionResponseData instance:

LoadCollectionResponseData responseData; 
string name = null; 
DateTime recordDate; 
decimal cost; 
decimal newCost = Convert.ToDecimal(100.0); 
Guid id; 

// Perform LoadCollection: 
// Access internal value for strings: 
name = responseData[0, "Name"].Value; 

// Convert internal date to DateTime: 
recordDate = responseData[0, "RecordDate"].GetValue<DateTime>(); 

// Convert to Decimal, specifying a default if the property is null: 
cost = responseData[0, "Cost"].GetValue<decimal>(Convert.ToDecimal(0.0)); 
id = responseData[0, "ID"].GetValue<Guid>(); 

// Assign a new value to cost: 
responseData[0, "Cost"].SetValue(newCost); 

Note that the Name property simply gets the internal format, since string values do not need conversion. Also note that the GetValue call for the cost property specifies an optional default value to return if the property is null. You can also check for null values using the IsNull property.

The last line assigns a new value to the 'Cost' property. Passing in a decimal value to the SetValue method allows the framework to perform the conversion to the internal string format automatically.