다음을 통해 공유


리소스 주소 지정을 위한 URI 형식(ADO.NET 데이터 서비스 프레임워크)

ADO.NET 데이터 서비스에서 액세스할 수 있는 모든 엔터티는 URI로 주소를 지정할 수 있습니다. ADO.NET 데이터 서비스 URI는 일반 URI 문법을 따르며 HTTP(Hypertext Transfer Protocol)를 사용합니다. ADO.NET 데이터 서비스 URI는 서비스 루트, 리소스 경로 및 쿼리 옵션의 세 섹션으로 이루어지며, 이 세 섹션이 모여 ADO.NET 데이터 서비스에서 모든 리소스의 주소 지정에 사용되는 URI를 구성합니다.

서비스 루트

URI의 서비스 루트 섹션은 ADO.NET 데이터 서비스의 루트 위치를 나타냅니다. ADO.NET 데이터 서비스 루트와 연결된 리소스는 모든 EntitySet, AssociationSet 및/또는 서비스의 서비스 작업에 대해 설명합니다. 스키마 및 서비스 이름 요소만 포함하는 올바른 URI는 다음과 같습니다.

  • https://www.contoso.com

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

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

리소스 경로

URI의 리소스 경로 요소는 ADO.NET 데이터 서비스의 리소스를 식별하는 URI를 생성하기 위해 엔터티 집합, 엔터티 형식, 탐색 속성, 탐색 링크, 속성, 복합 형식 및 서비스 작업 이름을 구성하는 방법을 나타냅니다.

URI의 리소스 경로 요소를 통해 데이터 서비스의 엔터티 그래프를 필터링하고 그래프 내에서 이동할 수 있습니다. 요청에 대한 응답 형식을 지정된 URI로 변경하기 위한 구문은 이 섹션에 포함되지 않습니다. 응답 형식을 변경하는 방법에 대한 자세한 내용은 ADO.NET 데이터 서비스 쿼리 옵션을 참조하십시오.

스키마, 서비스 루트 및 리소스 경로 요소를 포함하는 올바른 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 데이터 서비스 프레임워크)를 참조하십시오.

쿼리 옵션

URI의 쿼리 옵션 섹션은 시스템 쿼리 옵션과 서비스 작업 매개 변수라는 두 가지 종류의 정보를 지정합니다. 쿼리 옵션은 다음 규칙을 따릅니다.

  • 단일 URI 쿼리 문자열에서 지원되는 쿼리 옵션을 개수에 제한 없이 지정할 수 있습니다.

  • 각 쿼리 옵션은 다른 옵션의 존재 여부에 관계없이 쿼리 문자열에서 지정할 수 있습니다.

  • URI 내에서 쿼리 옵션이 표시되는 순서는 중요하지 않습니다.

  • 쿼리 옵션 이름은 대/소문자를 구분합니다.

  • 쿼리 옵션 값은 대/소문자를 구분합니다.

  • 특정 시스템 쿼리 옵션은 요청 URI의 쿼리 문자열에서 한 번만 나올 수 있습니다.

쿼리 의미 체계에 대한 자세한 내용은 ADO.NET 데이터 서비스 쿼리 옵션ADO.NET 데이터 서비스 시스템 쿼리 옵션을 참조하십시오.

예제

다음 URI는 ADO.NET 데이터 서비스 구문을 보여 주는 예제입니다. 각 예제에는 서비스에서 예제를 구문 분석하는 방법에 대한 설명이 포함되어 있습니다.

데이터 원본의 모든 OrdersID 속성이 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에 정의된 보강된 Backus-Naur 형식 사양에 따라 ADO.NET 데이터 서비스 URI를 생성하기 위한 구문 요소를 보여 줍니다. ADO.NET 데이터 서비스 URI는 서비스 루트, 리소스 경로 및 쿼리 옵션의 세 섹션으로 이루어지며, 이 세 섹션이 모여 ADO.NET 데이터 서비스에서 모든 리소스의 주소를 지정하는 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 데이터 서비스 프레임워크)를 참조하십시오.

참고 항목

개념

리소스 경로 규칙 및 의미 체계(ADO.NET 데이터 서비스 프레임워크)
ADO.NET 데이터 서비스 쿼리 옵션
ADO.NET 데이터 서비스 시스템 쿼리 옵션