UserDefinedTypeFormat property

The UserDefinedTypeFormat property of IfxConnection and IfxCommand sets the mapping of user-defined types to either DbType.String or DbType.Binary. Use this property instead of FetchExtendedTypesAs.

To access user-defined types as String objects, set the UserDefinedTypeFormat attribute or the UserDefinedTypeFormat property to string, "", or null. UDT columns and parameters are mapped to DbType.String. The shorthand, UDTFormat, is also a valid connection string attribute. These settings are not case-sensitive.

To access user-defined types as Byte[] objects, set the UserDefinedTypeFormat attribute or the UserDefinedTypeFormat property to bytes. UDT columns and parameters are mapped to DbType.Binary. The IfxType property of a parameter or column is not affected.

The following table shows what the IfxDataReader access methods, GetBytes() and GetString(), return depending on the setting of the UserDefinedTypeFormat property.
Table 1. Results for the UserDefinedTypeFormat setting with IfxDataReader access methods
UserDefinedTypeFormat SettingOperationResult
stringGetBytes()Invalid cast exception
stringGetString()Returns a string
bytesGetBytes()Returns bytes
bytesGetString()Returns the binary value as a hexadecimal string
When an IfxCommand object is bound to a connection, the object takes the UserDefinedTypeFormat property of that connection. Later changes to the connection setting of the property do not affect the IfxCommand object. Use one of the following ways to associate a command with a connection:
  • IfxConnection.CreateCommand()
  • IfxCommand.Connection_set()
  • IfxCommand.DbConnection_set()
  • IfxCommand(string cmdText, IfxConnection connection)
  • IfxCommand(string cmdText, IfxConnection connection, IfxTransaction transaction)
You can set the UserDefinedTypeFormat property of an IfxCommand independently from the UserDefinedTypeFormat property of its connection, but you cannot set it during the following times:
  • When executing a command
  • Between the first call of an IfxDataReader.Read() method and the closing of that data reader.