DataConnector | ComponentOne
ADO.NET provider for CSV / Configuration
In This Topic
    Configuration
    In This Topic

    To create a configuration for a CSV source from either a local or HTTP location, you need to configure the tables in the database. Each table should have four sections: SelectOperation, InsertOperation, UpdateOperation, and DeleteOperation.

    In the following example, the <Table> tag is used to configure each table in the database and divide it into the sections discussed above. To enable CRUD operations for an HTTP/HTTPS CSV source, the provider offers custom API configurations through a configuration file. The API configuration file should be in XML format and should include the configuration for all CRUD operations supported by the CSV source.

    Supported Data Types

    The supported data types for Column in the Api Config file are:

    Type Description
    byte Represents an unsigned 8-bit integer value.
    sbyte Represents a signed 8-bit integer value.
    short Represents a signed 16-bit integer value.
    ushort Represents an unsigned 16-bit integer value.
    int Represents a signed 32-bit integer value.
    uint Represents an unsigned 32-bit integer value.
    long Represents a signed 64-bit integer value.
    ulong Represents an unsigned 64-bit integer value.
    float Represents a single-precision floating-point number.
    double Represents a double-precision floating-point number.
    decimal Represents a high-precision decimal floating-point number.
    char Represents a Unicode character.
    bool Represents a Boolean value indicating true or false.
    string Represents a sequence of characters.
    DateTime Represents a date and time value.
    TimeSpan Represents a time interval.
    DateTimeOffset Represents a date and time value with an offset from UTC.
    Guid Represents a globally unique identifier.

    Below is an example of an XML API configuration file:

    XML
    Copy Code
    <Api_Config>
       <Table name="Album">
          <SelectOperation>
             <Uri>"GET_url"/Album</Uri>
             <Method>Get</Method>
             <Response>
                <TableName name="Album" type="string"></TableName>
                <Column name="AlbumId" isKey="true" type="int">AlbumId</Column>
                <Column name="Title" type="string">Title</Column>
                <Column name="ArtistId" type="int">ArtistId</Column>
             </Response>
          </SelectOperation>
          <InsertOperation>
             <Uri>"POST_url"/Album</Uri>
             <Method>Post</Method>
             <Body>
                <TableName name="Album" type="string"/>
                <Column name="AlbumId" type="int">AlbumId</Column>
                <Column name="Title" type="string">Title</Column>
                <Column name="ArtistId" type="int">ArtistId</Column>
             </Body>
          </InsertOperation>
          <UpdateOperation>
             <Uri>"PUT_url"/Album</Uri>
             <Method>PUT</Method>
             <Body>
                <TableName name="Album" type="string"/>
                <Column name="AlbumId" type="int">AlbumId</Column>
                <Column name="Title" type="string">Title</Column>
                <Column name="ArtistId" type="int">ArtistId</Column>
             </Body>
          </UpdateOperation>
          <DeleteOperation>
             <Uri>"DELETE_url"/api/Album/{Param1}</Uri>
             <Method>DELETE</Method>
             <Paramter name="Param1" type="int">AlbumId</Paramter>
          </DeleteOperation>
       </Table>
       <Table name="Customer">
          <SelectOperation>
             <Uri>"GET_url"/Customer</Uri>
             <Method>Get</Method>
             <Response>
                <TableName name="Customer" type="string"></TableName>
                <Column name="CustomerId" isKey="true" type="int">CustomerId</Column>
                <Column name="FirstName" type="string">FirstName</Column>
             </Response>
          </SelectOperation>
          <InsertOperation>
             <Uri>"POST_url"/api/Customer</Uri>
             <Method>Post</Method>
             <Body>
                <TableName name="Customer" type="string"/>
                <Column name="CustomerId" isKey="true" type="int">CustomerId</Column>
                <Column name="FirstName" type="string">FirstName</Column>
             </Body>
          </InsertOperation>
          <UpdateOperation>
             <Uri>"PUT_url"/Customer</Uri>
             <Method>PUT</Method>
             <Body>
                <TableName name="Customer" type="string"/>
                <Column name="CustomerId" isKey="true" type="int">CustomerId</Column>
                <Column name="FirstName" type="string">FirstName</Column>
             </Body>
          </UpdateOperation>
          <DeleteOperation>
             <Uri>"DELETE_url"/Customer/{Param1}</Uri>
             <Method>DELETE</Method>
             <Paramter name="Param1" type="int">CustomerId</Paramter>
          </DeleteOperation>
       </Table>
    </Api_Config>

    The API configuration file can be passed to the provider through the API Config File property in the connection string:

    C#
    Copy Code
    static string csvConnectionString = $"Uri='<uri>';API Config File='api_config.xml'";