0

I have a service operation of the form:

[WebGet]
public IQueryable<BusinessObject> BusinessObjectsByType(string name)

with access rule

config.SetServiceOperationAccessRule("BusinessObjectsByType", ServiceOperationRights.All);

When I access this service operation through a web browser, it exposes the data but not in feeds and entries (AtomPub format) and neither does it let me use basic query options like $top, $orderby, etc complaining that these 'cannot be applied to the requested resource'. I have matched all requirements specified at http://msdn.microsoft.com/en-us/library/cc668788.aspx but to no success. Any help will be appreciated. Thanks.

4

1 に答える 1

0

BussinesObjectがエンティティとして認識されない場合、サービス操作は代わりにIEnumerableを返すかのように扱われます。クエリを機能させるには、サービス操作でIQueryableを返す必要があります。ここでTはエンティティタイプです。EFプロバイダーまたはReflectionプロバイダーのいずれかを想定すると、エンティティタイプは、キープロパティ(ヒューリスティックまたはDataServiceKey属性のいずれかによる)を持ち、タイプIQueryableのコンテキストクラスにプロパティがあるタイプです。BussinesObjectがエンティティでない場合、WCFDataServicesはサービス操作の結果に対するクエリをサポートできません。1つだけ挙げると、多くの理由があります。応答をシリアル化するには、各オブジェクトに一意のURL(atom:id)が必要です。一意のURLを生成できるようにするには、オブジェクトにキープロパティが必要です。また、主要なプロパティはエンティティでのみ定義できます。

于 2010-06-24T09:22:31.297 に答える