28.01.2013 Views

SAP HANA Developer Guide - Get a Free Blog

SAP HANA Developer Guide - Get a Free Blog

SAP HANA Developer Guide - Get a Free Blog

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

OData Property Projection<br />

If the object you want to expose with an OData service has more columns than you actually want to expose, you<br />

can use SQL views to restrict the number of selected columns in the SELECT.<br />

Nevertheless, SQL views are sometimes not appropriate, for example with calculation views, and for these cases<br />

we provide the possibility to restrict the properties in the OData service definition in two ways. By providing an<br />

including or an excluding list of columns.<br />

Including Properties<br />

You can specify the columns of an object that have to be exposed in the OData service by using the with keyword.<br />

Key fields of tables must not be omitted.<br />

Service definition sample.odata:with.xsodata<br />

service {<br />

"sample.odata:table.hdbtable" as "MyTable" with ("ID","Text");<br />

}<br />

The resulting EntityType then contains only the properties derived from the specified columns:<br />

http://localhost:8002/sample/odata/with.xsodata/$metadata<br />

Excluding Properties<br />

The opposite of the with keyword is the without keyword, which enables you to specify which columns you do<br />

NOT want to expose in the OData service:<br />

Service definition sample.odata::without.xsodata<br />

service {<br />

"sample.odata:table.hdbtable" as "MyTable" without ("Text","Time");<br />

}<br />

The generated EntityType then does NOT contain the properties derived from the specified columns:<br />

http://localhost:8002/sample/odata/without.xsodata/$metadata<br />

192<br />

P U B L I C<br />

© 2012 <strong>SAP</strong> AG. All rights reserved.<br />

<strong>SAP</strong> <strong>HANA</strong> <strong>Developer</strong> <strong>Guide</strong><br />

Defining Web-based Data Access

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!