RetrieveEntity 要求を使用して、クライアントで eXtreme Scale エンティティーを取得できます。応答ペイロードには、AtomPub または JSON フォーマットのエンティティー・データが含まれます。 また、システム・オペレーター $expand を使用して、関係を拡張できます。 関係は、Atom Feed Document (対多関係) または Atom Entry Document (対 1 関係) として、データ・サービスの応答内に線で表されます。
以下の RetrieveEntity の例では、キーで Customer エンティティーを取得します。
AtomPubGET
http://localhost:8080/wxsrestservice/restservice/NorthwindGrid/Customer('ACME')
Accept: application/atom+xml
なし
Content-Type: application/atom+xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<entry xml:base = "http://localhost:8080/wxsrestservice/
restservice" xmlns:d= "http://schemas.microsoft.com/ado/2007/
08/dataservices" xmlns:m = "http://schemas.microsoft.com/ado/2007/
08/dataservices/metadata" xmlns = "http://www.w3.org/2005/Atom">
<category term = "NorthwindGridModel.Customer" scheme = "http://
schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<id>http://localhost:8080/wxsrestservice/restservice/
NorthwindGrid/Customer('ACME')</id>
<title type = "text"/>
<updated>2009-12-16T19:52:10.593Z</updated>
<author>
<name/>
</author>
<link rel = "edit" title = "Customer" href = "Customer(
'ACME')"/>
<link rel = "http://schemas.microsoft.com/ado/2007/08/
dataservices/related/
orders" type = "application/atom+xml;type=feed" title =
"orders" href ="Customer('ACME')/orders"/>
<content type = "application/xml">
<m:properties>
<d:customerId>ACME</d:customerId>
<d:city m:null = "true"/>
<d:companyName>RoaderRunner</d:companyName>
<d:contactName>ACME</d:contactName>
<d:country m:null = "true"/>
<d:version m:type = "Edm.Int32">3</d:version>
</m:properties>
</content>
</entry>
200 OK
GET
http://localhost:8080/wxsrestservice/restservice/NorthwindGrid/Customer('ACME')
Accept: application/json
なし
Content-Type: application/json
{"d":{"__metadata":{"uri":"http://localhost:8080/wxsrestservice/
restservice/NorthwindGrid/Customer('ACME')",
"type":"NorthwindGridModel.Customer"},
"customerId":"ACME",
"city":null,
"companyName":"RoaderRunner",
"contactName":"ACME",
"country":null,
"version":3,
"orders":{"__deferred":{"uri":"http://localhost:8080/
wxsrestservice/restservice/
NorthwindGrid/Customer('ACME')/orders"}}}}
200 OK
RetrieveEntitySet 要求または RetrieveEntity 要求で照会を使用することもできます。 照会は、$filter システム・オペレーターで指定します。
$filter オペレーターの詳細については、MSDN: Filter System Query Option ($filter) を参照してください。
OData プロトコルは、いくつかの一般的な式をサポートします。 eXtreme Scale REST データ・サービスは、仕様で定義されている式の以下のサブセットをサポートします。
以下の式は、使用できません。
Microsoft WCF Data Services で使用可能な式の完全なリストおよび説明については、セクション 2.2.3.6.1.1 (Common Expression Syntax) を参照してください。
以下の例では、照会を使用した RetrieveEntity 要求を示します。 この例では、契約名が「RoadRunner」であるすべての Customer が取得されます。 応答ペイロードに示すように、このフィルターに一致する唯一の Customer は Customer('ACME') です。
<?xml version="1.0" encoding="Shift_JIS"?>
<feed
xml:base="http://localhost:8080/wxsrestservice/restservice"
xmlns:d="http://schemas.microsoft.com/ado/2007/08/
dataservices"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/
dataservices/metadata"
xmlns="http://www.w3.org/2005/Atom">
<title type="text">Customer</title>
<id> http://localhost:8080/wxsrestservice/restservice/
NorthwindGrid/Customer </id>
<updated>2009-09-16T04:59:28.656Z</updated>
<link rel="self" title="Customer" href="Customer" />
<entry>
<category term="NorthwindGridModel.Customer"
scheme="http://schemas.microsoft.com/ado/2007/08/
dataservices/scheme" />
<id>
http://localhost:8080/wxsrestservice/restservice/NorthwindGrid/
Customer('ACME')</id>
<title type="text" />
<updated>2009-09-16T04:59:28.656Z</updated>
<author>
<name />
</author>
<link rel="edit" title="Customer" href="Customer('ACME')" />
<link
rel="http://schemas.microsoft.com/ado/2007/08/dataservices/
related/orders"
type="application/atom+xml;type=feed" title="orders"
href="Customer('ACME')/orders" />
<content type="application/xml">
<m:properties>
<d:customerId>ACME</d:customerId>
<d:city m:null = "true"/>
<d:companyName>RoaderRunner</d:companyName>
<d:contactName>ACME</d:contactName>
<d:country m:null = "true"/>
<d:version m:type = "Edm.Int32">3</d:version>
</m:properties>
</content>
</entry>
</feed>
http://localhost:8080/wxsrestservice/restservice/NorthwindGrid/Customer?$filter=contactName eq 'RoadRunner'
{"d":[{"__metadata":{"uri":"http://localhost:8080/wxsrestservice/
restservice/NorthwindGrid/Customer('ACME')",
"type":"NorthwindGridModel.Customer"},
"customerId":"ACME",
"city":null,
"companyName":"RoaderRunner",
"contactName":"ACME",
"country":null,
"version":3,
"orders":{"__deferred":{"uri":"http://localhost:8080/
wxsrestservice/restservice/NorthwindGrid/
Customer('ACME')/orders"}}}]}
$expand システム・オペレーターを使用して、アソシエーションを拡張できます。 データ・サービス応答内で、アソシエーションは線で表されます。 多値 (対多) アソシエーションは、Atom Feed Document または JSON 配列として表されます。 単一値 (対 1) アソシエーションは、Atom Entry Document または JSON オブジェクトとして表されます。
$expand システム・オペレーターの詳細については、Expand System Query Option ($expand) を参照してください。
ここでは、$expand システム・オペレーターの使用例を示します。 この例では、5000、5001、およびその他の Order が関連付けられているエンティティー Customer('IBM') を取得します。 $expand 節は「orders」に設定され、応答ペイロード内で、オーダー・コレクションはインラインで拡張されます。 この例では、5000 および 5001 の Order のみが表示されます。
<?xml version="1.0" encoding="utf-8"?>
<entry xml:base = "http://localhost:8080/wxsrestservice/restservice"
xmlns:d ="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns:m = "http://schemas.microsoft.com/ado/2007/08/dataservices/
metadata" xmlns = "http://www.w3.org/2005/Atom">
<category term = "NorthwindGridModel.Customer" scheme = "http://schemas.
microsoft.com/ado/2007/08/dataservices/scheme"/>
<id>http://localhost:8080/wxsrestservice/restservice/NorthwindGrid/
Customer('IBM')</id>
<title type = "text"/>
<updated>2009-12-16T22:50:18.156Z</updated>
<author>
<name/>
</author><link rel = "edit" title = "Customer" href =
"Customer('IBM')"/>
<link rel = "http://schemas.microsoft.com/ado/2007/08/dataservices/
related/orders" type = "application/atom+xml;type=feed" title =
"orders" href = "Customer('IBM')/orders">
<m:inline>
<feed>
<title type = "text">orders</title>
<id>http://localhost:8080/wxsrestservice/restservice/
NorthwindGrid/Customer('IBM')/orders</id>
<updated>2009-12-16T22:50:18.156Z</updated>
<link rel = "self" title = "orders" href = "Customer
('IBM')/orders"/>
<entry>
<category term = "NorthwindGridModel.Order" scheme =
"http://schemas.microsoft.com/ado/2007/08/
dataservices/scheme"/>
<id>http://localhost:8080/wxsrestservice/restservice/
NorthwindGrid/Order(orderId=5000,customer_customerId=
'IBM')</id>
<title type = "text"/>
<updated>2009-12-16T22:50:18.156Z</updated>
<author>
<name/>
</author>
<link rel = "edit" title = "Order" href =
"Order(orderId=5000,customer_customerId='IBM')"/>
<link rel = "http://schemas.microsoft.com/ado/2007/08/
dataservices/related/customer" type = "application/
atom+xml;type=entry" title ="customer" href =
"Order(orderId=5000,customer_customerId='IBM')/customer"/>
<link rel = "http://schemas.microsoft.com/ado/2007/08/
dataservices/related/orderDetails" type = "application/
atom+xml;type=feed" title ="orderDetails" href =
"Order(orderId=5000,customer_customerId='IBM')/orderDetails"/>
<content type = "application/xml">
<m:properties>
<d:orderId m:type = "Edm.Int32">5000</d:orderId>
<d:customer_customerId>IBM</d:customer_customerId>
<d:orderDate m:type = "Edm.DateTime">
2009-12-16T19:46:29.562</d:orderDate>
<d:shipCity>Rochester</d:shipCity>
<d:shipCountry m:null = "true"/>
<d:version m:type = "Edm.Int32">0</d:version>
</m:properties>
</content>
</entry>
<entry>
<category term = "NorthwindGridModel.Order" scheme =
"http://schemas.microsoft.com/ado/2007/08/
dataservices/scheme"/>
<id>http://localhost:8080/wxsrestservice/restservice/
NorthwindGrid/Order(orderId=5001,customer_customerId=
'IBM')</id>
<title type = "text"/>
<updated>2009-12-16T22:50:18.156Z</updated>
<author>
<name/></author>
<link rel = "edit" title = "Order" href = "Order(
orderId=5001,customer_customerId='IBM')"/>
<link rel = "http://schemas.microsoft.com/ado/2007/
08/dataservices/related/customer" type =
"application/atom+xml;type=entry" title =
"customer" href = "Order(orderId=5001,customer_customerId=
'IBM')/customer"/>
<link rel = "http://schemas.microsoft.com/ado/2007/08/
dataservices/related/orderDetails" type =
"application/atom+xml;type=feed" title =
"orderDetails" href = "Order(orderId=5001,
customer_customerId='IBM')/orderDetails"/>
<content type = "application/xml">
<m:properties>
<d:orderId m:type = "Edm.Int32">5001</d:orderId>
<d:customer_customerId>IBM</d:customer_customerId>
<d:orderDate m:type = "Edm.DateTime">2009-12-16T19:
50:11.125</d:orderDate>
<d:shipCity>Rochester</d:shipCity>
<d:shipCountry m:null = "true"/>
<d:version m:type = "Edm.Int32">0</d:version>
</m:properties>
</content>
</entry>
</feed>
</m:inline>
</link>
<content type = "application/xml">
<m:properties>
<d:customerId>IBM</d:customerId>
<d:city m:null = "true"/>
<d:companyName>IBM Corporation</d:companyName>
<d:contactName>John Doe</d:contactName>
<d:country m:null = "true"/>
<d:version m:type = "Edm.Int32">4</d:version>
</m:properties>
</content>
</entry>
{"d":{"__metadata":{"uri":"http://localhost:8080/wxsrestservice/
restservice/NorthwindGrid/Customer('IBM')",
"type":"NorthwindGridModel.Customer"},
"customerId":"IBM",
"city":null,
"companyName":"IBM Corporation",
"contactName":"John Doe",
"country":null,
"version":4,
"orders":[{"__metadata":{"uri":"http://localhost:8080/
wxsrestservice/restservice/NorthwindGrid/Order(
orderId=5000,customer_customerId='IBM')",
"type":"NorthwindGridModel.Order"},
"orderId":5000,
"customer_customerId":"IBM",
"orderDate":"¥/Date(1260992789562)¥/",
"shipCity":"Rochester",
"shipCountry":null,
"version":0,
"customer":{"__deferred":{"uri":"http://localhost:8080/
wxsrestservice/restservice/NorthwindGrid/Order(
orderId=5000,customer_customerId='IBM')/customer"}},
"orderDetails":{"__deferred":{"uri":"http://localhost:
8080/wxsrestservice/restservice/NorthwindGrid/
Order(orderId=5000,customer_customerId='IBM')/
orderDetails"}}},
{"__metadata":{"uri":"http://localhost:8080/wxsrestservice/
restservice/NorthwindGrid/Order(orderId=5001,
customer_customerId='IBM')","type":
"NorthwindGridModel.Order"},
"orderId":5001,
"customer_customerId":"IBM",
"orderDate":"¥/Date(1260993011125)¥/",
"shipCity":"Rochester",
"shipCountry":null,
"version":0,
"customer":{"__deferred":{"uri":"http://localhost:
8080/wxsrestservice/restservice/
NorthwindGrid/Order(orderId=5001,customer_customerId
='IBM')/customer"}},
"orderDetails":{"__deferred":{"uri":"http://localhost:8080/
wxsrestservice/restservice/NorthwindGrid/Order(
orderId=5001, customer_customerId='IBM')/
orderDetails"}}}]}}