ODP.NET Types Overview
ODP.NET types represent Oracle native data types and PL/SQL data types as a structure or as a class. ODP.NET type structures follow value semantics, while ODP.NET type classes follow reference semantics. ODP.NET types provide safer and more efficient ways of obtaining Oracle native data and PL/SQL data types in a .NET application than .NET types. For example, an OracleDecimal
structure holds up to 38 digits of precision, while a .NET Decimal
only holds up to 28.
Table 3-14 lists data types supported by ODP.NET and their corresponding ODP.NET types: data types in the first column refer to both Oracle native data types and PL/SQL data types of that name. Those data types that exist only in PL/SQL are indicated by (PL/SQL only) after the data type name. The entries for the PL/SQL data types also represent the subtypes of the data types, if any. The third column lists the .NET Framework data type that corresponds to the Value
property of each ODP.NET type.
Table 3-14 Value Property Type of ODP.NET Type
Oracle Native Data Type or PL/SQL Data Type | ODP.NET Type | .NET Framework Data Types |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Not Applicable |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Deserializing ODP.NET Types into DataSet and DataTable
Due to a change in all .NET versions to enhance application security, the allowed DataSet
and DataTable
data types that can be deserialized are now restricted. This change applies to .NET 5, plus .NET Core and .NET Framework updates. If your DataSets
and DataTables
use Oracle data types with one of these new .NET versions, then you will have to add ODP.NET-specific data types to the “allow” list so that they can be deserialized into DataSet
or DataTable
. If an attempt is made to deserialize ODP.NET-specific types without adding them to the allow list, an ODP.NET type initializer exception will be encountered.
The most straightforward way to add all ODP.NET data types to the allow list to call the OracleConfiguration
AddOracleTypesDeserialization
method in your application.
Alternatively, in .NET Framework 4, the specific ODP.NET data types can be added individually to the application .NET configuration file. Here's a sample configuration file for adding all managed ODP.NET 21c data types to the allow list.
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <sectionGroup name="system.data.dataset.serialization" type="System.Data.SerializationSettingsSectionGroup, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <section name="allowedTypes" type="System.Data.AllowedTypesSectionHandler, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> </sectionGroup> </configSections> <system.data.dataset.serialization> <allowedTypes> <!-- <add type="assembly qualified type name" /> --> <add type="Oracle.ManagedDataAccess.Types.OracleBinary, Oracle.ManagedDataAccess, Version=4.122.21.1, Culture=neutral, PublicKeyToken=89b483f429c47342" /> <add type="Oracle.ManagedDataAccess.Types.OracleBlob, Oracle.ManagedDataAccess, Version=4.122.21.1, Culture=neutral, PublicKeyToken=89b483f429c47342" /> <add type="Oracle.ManagedDataAccess.Types.OracleClob, Oracle.ManagedDataAccess, Version=4.122.21.1, Culture=neutral, PublicKeyToken=89b483f429c47342" /> <add type="Oracle.ManagedDataAccess.Types.OracleDate, Oracle.ManagedDataAccess, Version=4.122.21.1, Culture=neutral, PublicKeyToken=89b483f429c47342" /> <add type="Oracle.ManagedDataAccess.Types.OracleDecimal, Oracle.ManagedDataAccess, Version=4.122.21.1, Culture=neutral, PublicKeyToken=89b483f429c47342" /> <add type="Oracle.ManagedDataAccess.Types.OracleIntervalDS, Oracle.ManagedDataAccess, Version=4.122.21.1, Culture=neutral, PublicKeyToken=89b483f429c47342" /> <add type="Oracle.ManagedDataAccess.Types.OracleIntervalYM, Oracle.ManagedDataAccess, Version=4.122.21.1, Culture=neutral, PublicKeyToken=89b483f429c47342" /> <add type="Oracle.ManagedDataAccess.Types.OracleRef, Oracle.ManagedDataAccess, Version=4.122.21.1, Culture=neutral, PublicKeyToken=89b483f429c47342" /> <add type="Oracle.ManagedDataAccess.Types.OracleString, Oracle.ManagedDataAccess, Version=4.122.21.1, Culture=neutral, PublicKeyToken=89b483f429c47342" /> <add type="Oracle.ManagedDataAccess.Types.OracleTimeStamp, Oracle.ManagedDataAccess, Version=4.122.21.1, Culture=neutral, PublicKeyToken=89b483f429c47342" /> <add type="Oracle.ManagedDataAccess.Types.OracleTimeStampLTZ, Oracle.ManagedDataAccess, Version=4.122.21.1, Culture=neutral, PublicKeyToken=89b483f429c47342" /> <add type="Oracle.ManagedDataAccess.Types.OracleTimeStampTZ, Oracle.ManagedDataAccess, Version=4.122.21.1, Culture=neutral, PublicKeyToken=89b483f429c47342" /> <add type="Oracle.ManagedDataAccess.Types.OracleXmlType, Oracle.ManagedDataAccess, Version=4.122.21.1, Culture=neutral, PublicKeyToken=89b483f429c47342" /> <!-- additional <add /> elements as needed --> </allowedTypes> </system.data.dataset.serialization> </configuration>
With the .NET configuration file, developers can enable specific ODP.NET data types to allow, rather than enable all of them with AddOracleTypesDeserialization
method.