Creating a Data Service¶
Creating the datasource connection¶
Follow the steps given below to create the data service file:
Select the already created Data Service Project in the project navigator, right click and go to New -> Data Service.
The New Data Service window will open as shown below.
To start creating a data service from scratch, select Create New Data Service and click Next.
- Enter a name for the data service.
- Click Next and start adding the datasource connection details.
- Save the data service.
A data service file (DBS file) will now be created in your data service project. Shown below is the project directory.
Creating a query¶
- Select the data service you created in the previous step.
- Right-click and click Add Query.
- Enter the query details.
- Save the query. The query element is now added to the data
Add an SQL¶
- Right-click the query and click Add SQL to add the statement.
- Save the SQL statement.
Add Input mapping¶
- Right-click the query again and click Add Input Mapping.
- Enter the input mapping details.
- Save the input mapping.
Add Output mapping¶
- Right-click the query again and click Add Output Mapping.
- Enter the following value to group the output mapping:
- Save the output mapping.
Add Output mapping element¶
- Right-click the output mapping and go to Add Output Mapping → Add Element to create an element.
- Enter the following element details.
- Save the element.
- Save the output elements.
The data service should now have the query element added as shown below.
Creating a resource to invoke the query¶
Now, let's create a REST resource that can be used to invoke the query.
- Right-click the data service and click Add Resource. Add the following resource details.
- Expand the GET resource, and click the GetEmployeeDetails (call-query). Connect the query to the resource by adding the following:
- Save the resource.
The data service should now have the resource added as shown below.
- Exposing an RDBMS Datasource
- Exposing Data in JSON Format
- Using and OData Service
- Using Nested Data Queries
- Batch Requesting
- Invoking Multiple Operations via Request Box
- Using Distributed Transactions in Data Services
- Validating Data Input