私は最近、RIAサービスからのoDataフィードで遊ぶためのサンプルプロジェクトの作成を開始しました。任意のWebブラウザーを介してフィードとメタデータを表示できますが、フィードに対して特定のクエリ操作を実行しようとすると、「サポートされていない」例外が発生します。
サンプルoDataフィード:
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<feed
xml:base="http://localhost:50880/Services/
Rebirth-Web-Services-ProductService.svc/OData/"
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">ProductSet</title>
<id>http://localhost:50880/Services/
Rebirth-Web-Services-ProductService.svc/OData/ProductSet/</id>
<updated>2010-04-28T14:02:10Z</updated>
<link rel="self" title="ProductSet" href="ProductSet" />
<entry>
<id>http://localhost:50880/Services/
Rebirth-Web-Services-ProductService.svc/OData/ProductSet
(guid'b0a2b170-c6df-441f-ae2a-74dd19901128')</id>
<title type="text"></title>
<updated>2010-04-28T14:02:10Z</updated>
<author>
<name />
</author>
<link rel="edit" title="Product"
href="ProductSet(guid'b0a2b170-c6df-441f-ae2a-74dd19901128')" />
<category term="Rebirth.Web.Models.Product"
scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<content type="application/xml">
<m:properties>
<d:Id m:type="Edm.Guid">b0a2b170-c6df-441f-ae2a-74dd19901128</d:Id>
<d:Name>Product 0</d:Name>
<d:ProductType>Type 1</d:ProductType>
<d:Status>Active</d:Status>
</m:properties>
</content>
</entry>
サンプルweb.configエントリ:
<add name="OData"
type="System.ServiceModel.DomainServices.Hosting.ODataEndpointFactory,
System.ServiceModel.DomainServices.Hosting.OData,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
サンプルサービス:
[EnableClientAccess()]
public class ProductService : DomainService {
[Query(IsDefault = true)]
public IQueryable<Product> GetProducts() {
IList<Product> products = new List<Product>();
for (int i = 0; i < 90; i++) {
Product product = new Product {
Id = Guid.NewGuid(),
Name = "Product " + i.ToString(),
ProductType = i < 30 ? "Type 1" :
((i > 30 && i < 60) ? "Type 2" : "Type 3"),
Status = i % 2 == 0 ? "Active" : "NotActive"
};
products.Add(product);
}
return products.AsQueryable();
}
}
URL「http:// localhost:50880 / Services / Rebirth-Web-Services-ProductService.svc / OData / ProductSet( guid'b0a2b170-c6df-441f-ae2a-74dd19901128')」をWebブラウザーに提供すると、次のxml:
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code/>
<message xml:lang="en-US"
xmlns:xml="http://www.w3.org/XML/1998/namespace">
Requests that attempt to access a single element using key values
from a result set are not supported.
</message>
</error>
私はRIAとoDataを初めて使用します。これは、私のWebブラウザーが結果セットなどでこのタイプのクエリをサポートしていないのと同じくらい単純なものでしょうか?
編集:これは私がLinqPadで見るものです:
Member qRuntimeMethodInfo
QueryResult.Execute ()
StackTrace
at System.Data.Services.Client.QueryResult.Execute()
at System.Data.Services.Client.DataServiceRequest.Execute[TElement]
(DataServiceContext context, QueryComponents queryComponents)