DataDirect Classes


The DataDirect data providers support additional classes that provide enhanced functionality, such as bulk load. All classes are created with 100% managed code. The following classes are provided in the DDTek.Data.Common.dll assembly:

Because the classes used for bulk loading use the generic programming model, they can be used with any DataDirect data provider and any supported database.

CsvDataReader

The CsvDataReader class provides the DataReader semantics for the CSV file format defined by DataDirect Bulk Load.

Table B-55. Public Properties of the CsvDataReader Object 
Property
Description

BulkConfigFile

Specifies the CSV bulk configuration file that describes bulk data. See Appendix A "Bulk Load Configuration Files" for an example of the CSV bulk configuration file.

The path may be fully qualified, otherwise the file is considered to exist in the current working directory.

NOTE: This property can only be set prior to the Open() call and after the Close() call; otherwise, an InvalidOperationException is thrown.

BulkFile

Specifies the bulk data file that contains the CSV-formatted bulk data. The path may be fully qualified. Otherwise, the file is considered by default to exist in the current working directory. An InvalidOperationException is thrown if this value is not set.

NOTE: This property can only be set prior to the Open() call and after the Close() call; otherwise, an InvalidOperationException is thrown.

ReadBufferSize

Specifies the size of the read buffer when using bulk load to import data from a data source.

The initial default is 2048 KB.

Values equal to or less than zero throw System.ArgumentOutOfRangeException.

RowOffset

Specifies the row from which to start the bulk load read. The RowOffset is relative to the first (1) row.

The initial default is 1.

Values equal to or less than zero throw System.ArgumentOutOfRangeException.

NOTE: This property can only be set prior to the Open() call and after the Close() call; otherwise, an InvalidOperationException is thrown.

SequentialAccess

Determines whether columns are accessed in order for improved performance.

The initial default is False.

NOTE: This property can only be set prior to the Open() call and after the Close() call; otherwise, an InvalidOperationException is thrown.

Table B-56 lists the public methods for the CsvDataReader object.

Table B-56. Public Methods of the CsvDataReader Object
Property
Description

Open

Opens the bulk file instance and associated metadata file for processing.

Table B-57 lists the public methods of the CsvDataReader object that have provider-specific information. For a description of the other methods supported, refer to the online help and the Microsoft .NET Framework SDK documentation.

Table B-57. Public Methods of the CsvDataReader Object  
Method
Description

GetBytes

Reads a stream of bytes from the specified column offset into the buffer as an array. The XML column is returned as raw binary form.

GetChars

Reads a stream of characters into the buffer as an array, starting from the specified buffer offset of the specified column offset. The XML column is returned as character data.

GetString

Gets the value of a specified column as a string. The XML column is returned as character data.

GetValue

Gets value of a column at a specified ordinal, returning the value in the column's native format.

GetValues

Gets all of the attribute columns in the current row.

CsvDataWriter

The CsvDataWriter class provides the DataWriter semantics of the CSV file format that is written by DataDirect Bulk Load.

The following C# code fragment writes the GBMAXTABLE.csv and GBMAXTABLE.xml files that will be created by the CsvDataWriter for a query on the Oracle table GBMAXTABLE.

cmd.CommandText = "SELECT * FROM GBMAXTABLE ORDER BY INTEGERCOL"; 
DbDataReader reader = cmd.ExecuteReader(); 
CsvDataWriter csvWriter = new CsvDataWriter(); 
csvWriter.WriteToFile("\\NC1\net\Oracle\GBMAXTABLE\GBMAXTABLE.csv", reader); 

For more information, refer to the data provider's online help.

Table B-58. Public Properties of the CsvDataWriter Object
Property
Description

BinaryThreshold

Specifies the threshold (in KB) at which separate files are generated to store binary data during a bulk unload.

The Initial default is 64.

Values less than zero throw System.ArgumentOutOfRangeException.

CharacterThreshold

Specifies the threshold (in KB) at which separate files are generated to store character data during a bulk unload.

The initial default is 64.

Values less than zero cause a System.ArgumentOutOfRangeException to be thrown.

CsvCharacterSetName

Specifies an IANA code page name. See Appendix C "IANA Code Page Mappings" for the supported values.

Applications can obtain the database character set that was set using the xxxConnection.DatabaseCharacterSetName property.

If the value of DatabaseCharacterSetName is not recognized, an exception is thrown, declaring that an invalid character set has been used.

The initial default value is UTF-16.

Note that this property enforces the character set used in the CSV data file (see "Bulk Load Data File") and the overflow files (see "External Overflow File").

Table B-59 lists the public methods for the CsvDataWriter object.

Table B-59. Public Methods of the CsvDataWriter Object
Property
Description

Open

Opens the bulk file instance and associated metadata file for processing.

WriteToFile

Writes the contents of the IDataReader to the bulk data file.

DbBulkCopy

The DbBulkCopy class facilitates copying rows from one data source to another.

The DbBulkCopy object follows the de facto standard defined by the Microsoft SqlBulkCopy class, and has no provider-specific properties or methods. For information about the properties and methods supported, refer to the data provider's online help and the Microsoft .NET Framework SDK documentation.

DbBulkCopyColumnMapping

The DbBulkCopyColumnMapping class represents a column mapping from the data sources table to a destination table.

The DbBulkCopyColumnMapping object follows the de facto standard defined by the Microsoft SqlBulkCopyColumnMapping class, and has no provider-specific properties or methods. For information about the properties and methods supported, refer to the data provider's online help and the Microsoft .NET Framework SDK documentation.

DbBulkCopyColumnMappingCollection

The DbBulkCopyColumnMappingCollection class is a collection of DbBulkCopyColumnMapping objects.

The DbBulkCopyColumnMappingCollection object follows the de facto standard defined by the Microsoft SqlBulkCopyColumnMappingCollection class, and has no provider-specific properties or methods. For information about the properties and methods supported, refer to the data provider's online help and the Microsoft .NET Framework SDK documentation.