DataConnector
構成
ADO.NET provider for JSON > 構成

To create a configuration for http JSON source, you need to configure the tables in the database and each table needs to be separated into four sections, namely SelectOperation, InsertOperation, UpdateOperation, and DeleteOperation -

In the following example, we use the <Table> tag to configure each table in the database and separate a table into the above discussed sections. To support CRUD for http/https JSON source, the provider supports custom API configurations using a configuration file. The API configuration file should be an XML containing the configuration for all the CRUD operations supported by the JSON source. Below is an example of an XML API configuration file:

HTML
コードのコピー
<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#
コードのコピー
static string documentConnectionString = $"Data Model=Document;Uri='<url>';Json Path='<json_paths>';API Config File='api_config.xml'";