One clause in Data Provider Group statement

Official Content
This documentation is valid for:

Allows return only the first record from a navigation of many.

Syntax

<One>::= [One]

Example

Suppose the SDT used as Output of the data provider is not a collection because we need only the first Customer of all possible. If the data provider is written as follows, the result was the last Customer (because the data provider will read all the table and would modify the SDT to return with each Customer).

OneCustomer
{
   CustomerId
   CustomerName
}

Data

CustomerId CustomerName
1 Customer one
2 Customer two
3 Customer three

 

The result would be:

<OneCustomer>
   <CustomerId>3</CustomerId>
   <CustomerName>Customer three</CustomerName>
</OneCustomer>

The generated select is as follows, which does not have good performance, because to obtain only one record it reads all the table.

SELECT [CustomerName], [CustomerId] FROM [Customer] WITH (NOLOCK) ORDER BY [CustomerId]

In order to improve this case the clause [one] was implemented, if we now write:

OneCustomer [one]
{
   CustomerId
   CustomerName
}

The result would be:

<OneCustomer>
   <CustomerId>1</CustomerId>
   <CustomerName>Customer one</CustomerName>
</OneCustomer>

The performance is improved because the generated select in that case is:

SELECT TOP 1 [CustomerName], [CustomerId] FROM [Customer] WITH (NOLOCK) ORDER BY [CustomerId]

We realise of that in the data provider navigation:

NavDPOne

 







Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.