リソースのアドレスを指定する URI 形式 (ADO.NET Data Services フレームワーク)

ADO.NET Data Services でアクセス可能なすべてのエンティティは、URI でアドレスを指定できます。ADO.NET Data Services の URI は一般的な URI の文法に準拠しており、HTTP (Hypertext Transfer Protocol) を使用しています。ADO.NET Data Services の URI は、サービス ルート、リソース パス、クエリ オプションの 3 つのセクションで構成されています。これらのセクションは、ADO.NET Data Services でリソースのアドレス指定に使用される URI を形成します。

サービス ルート

URI のサービス ルート セクションは、ADO.NET Data Services のルートの場所を表します。ADO.NET Data Services のルートに関連付けられたリソースでは、サービスのすべての EntitySetAssociationSet、およびサービス操作を記述します。スキームとサービス名の要素のみを含む有効な URI は次のとおりです。

  • https://www.contoso.com

  • http://::1:8080/myservice.svc

  • https://www.contoso.com/path/myservice.svc/

リソース パス

URI のリソース パス要素は、ADO.NET Data Services でリソースを特定する URI を生成するために、エンティティ セット、エンティティ型、ナビゲーション プロパティ、ナビゲーション リンク、プロパティ、複合型、サービス操作名がどのように構成されているかを示します。

URI のリソース パス要素により、データ サービス内のエンティティのグラフをフィルタ処理およびスキャンできます。このセクションには、指定の URI に対する要求の応答形式を変更する構造は含まれていません。応答形式の変更の詳細については、「ADO.NET Data Services のクエリ オプション」を参照してください。

スキーム、サービス ルート、およびリソース パスの要素を含む有効な URI は次のとおりです。

  • https://www.contoso.com/myservice.svc/Customers

  • https://www.contoso.com/Customers(123)

  • https://www.contoso.com/Customers(123)/Orders

  • https://www.contoso.com/Customers(123)/$links/Orders

  • https://www.contoso.com/Products(ID=’ABC’)/Category

  • https://www.contoso.com/Teams(Conference=’ACC’, League=’NCCC’)/Roster

リソース パスの構文の詳細については、「リソース パスの規則とセマンティクス (ADO.NET Data Services フレームワーク)」を参照してください。

クエリ オプション

URI のクエリ オプション セクションは、システム クエリ オプションとサービス操作パラメータの 2 種類の情報を指定します。クエリ オプションは、次の規則に従います。

  • サポートされているクエリ オプションであれば、任意の数のオプションを 1 つの URI クエリ文字列で指定できます。

  • 各クエリ オプションは、他のオプションの有無とは関係なく、クエリ文字列に存在できます。

  • URI 内のクエリ オプションの順序は重要ではありません。

  • クエリ オプション名では大文字と小文字が区別されます。

  • クエリ オプション値では大文字と小文字が区別されます。

  • 特定のシステム クエリ オプションは、要求 URI のクエリ文字列に一度だけ表示できます。

クエリ セマンティクスの詳細については、「ADO.NET Data Services のクエリ オプション」および「ADO.NET Data Services のシステム クエリ オプション」を参照してください。

次の URI は、ADO.NET Data Services 構文の例です。各 URI には、サービスによる解析方法についての説明が記載されています。

データ ソースのすべての Orders から、ID プロパティが 201 の Orders だけを返します。

http://host/service.svc/Orders?$filter=ID%20eq%201

fullname プロパティの値が 'Jones, David' と等しい、すべての Customers を照合します。

http://host/service.svc/Customers?$filter=
         'Jones, David' eq insert(fullname, length(lastname), ',')

算術式は (1 + 2) * 3 ではなく、1 + (2 * 3) として解析されます。このフィルタ式は単なるテスト用であり、常に True と評価されるので、この URI では、すべての OrderLines が要求の対象になります。

http://host/service.svc/OrderLines?$filter=1 add 2 mul 3 lt 10

抽象構文

次の規則は、RFC 4234 で規定されているバッカスナウア記法で ADO.NET Data Service の URI を構成するための構文要素を示しています。ADO.NET Data Service の URI は、サービス ルート、リソース パス、クエリ オプションの 3 つのセクションで構成されています。これらのセクションを構成すると、ADO.NET Data Service でリソースをアドレス指定するための URI が形成されます。

ADO.NET_DS_URI   = "http://" serviceRoot [ resourcePath ["?" queryOptions ] ] 

ServiceRoot      = host [ ":" port ] [*( "/" segment-nz )]

ResourcePath     = "/" EntitySet | serviceOperation [ navPath ]  

navPath          = ("("keyPredicate")" [ navPath_np / propertyPath / propertyPath_ct ] )

navPath_np       = "/" ("$links" / NavigationProperty) /
                     (NavigationProperty [ navPath ])

EntityPropertyPath     = "/" EntityProperty [ "/$value" ] 

ComplexTypePropertyPath_ct  = 1*("/" ComplexType) [ propertyPath ] 
  
keyPredicate     = keyPredicate_single | keyPredicate_cmplx

keyPredicate_single  = 1*DIGIT | ("’" 1*unreserved "’") | 1*(HEXDIGHEXDIG)) | 
                       keyPredicate_complex
                       //NOTE: strings, GUIDs and dates are quoted

keyPredicate_cmplx   = resourceProp "=" keyPredicate [“,” keyPredicate_cmplx]

queryOptions     = sysQueryOperation / serviceOpParamName 
                     *("&" sysQueryOperation / serviceOpParam)

DIGIT            = as defined in RFC 3986 (0-9)
Host             = as defined in RFC 3986
Port             = as defined in RFC 3986
segment-nz       = as defined in RFC 3986 (A non empty sequence of chars outside set of URI reserved characters.)
pchar            = as defined in RFC 3986 (A non empty sequence of chars outside set of URI reserved characters.)

serviceOperation = the name of a service operation. 

EntitySet      = the name of an EntitySet. Allowed characters match the set of allowed characters for EntitySet names in the EDM specification.

EntityType = The name of an EntityType within the EntitySet referenced in the prior path segment. Allowed characters match the set of allowed characters for EntityType names in the EDM specification.

Property     = The name of a property on the entity type or complex type in the prior path segment or current path segment if filtering by key. Allowed characters match the set of allowed characters for EntityType property names in the EDM specification.  

NavigationProperty = the name of a NavigationProperty or Navigation Link on the EntityType in the prior path segment. If the prior segment is an EntitySet,this property must be on the type within the given set. Allowed characters match the set of allowed characters for NavigationProperty names in the EDM specification.

systemQueryOperation = "$" query "=" query 

serviceOperationParam    = query "=" query  

URI 構文の詳細および例については、「リソース パスの規則とセマンティクス (ADO.NET Data Services フレームワーク)」を参照してください。

参照

概念

リソース パスの規則とセマンティクス (ADO.NET Data Services フレームワーク)
ADO.NET Data Services のクエリ オプション
ADO.NET Data Services のシステム クエリ オプション