DataServiceRequest<TElement> 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
데이터 서비스에 일괄 처리로 제출된 요청 개체를 나타냅니다.
generic <typename TElement>
public ref class DataServiceRequest sealed : System::Data::Services::Client::DataServiceRequest
public sealed class DataServiceRequest<TElement> : System.Data.Services.Client.DataServiceRequest
type DataServiceRequest<'Element> = class
inherit DataServiceRequest
Public NotInheritable Class DataServiceRequest(Of TElement)
Inherits DataServiceRequest
형식 매개 변수
- TElement
- 상속
예제
반환될 때 ExecuteBatch 일괄 처리 요청에 대한 전체 HTTP 응답은 네트워크 스트림에서 읽어왔지만 응답은 처리되지 않았습니다. ID 확인 및 개체 구체화는 다음 예제와 같이 반복될 때까지 응답에서 지정된 엔터티에 대해 발생하지 않습니다.
DataServiceContext service = new DataServiceContext(new
Uri("http://myserviceroot"));
// Create query batches.
DataServiceRequest[] reqs = new DataServiceRequest[] {
new DataServiceRequest<Category>(
new Uri("http://myserviceroot/Categories")),
new DataServiceRequest<Customer>(
new Uri("http://myserviceroot/Customers"))
};
DataServiceResponse dsr;
try
{
// Client will not throw an exception on ExecuteBatch because the
// entire response has not been processed yet to know
// whether an exception should be thrown.
dsr = service.ExecuteBatch(reqs);
if (dsr.IsBatchResponse)
{
/*inspect HTTP artifacts associated with the entire batch:
dsr.BatchHeaders, dsr.BatchStatusCode*/ }
foreach (QueryOperationResponse qr in dsr)
{
if (IsErrorStatusCode(qr.StatusCode))
{
//q.Error.Message contains the full contents of the error.
/* process any part of the Error Contract (<error> element)
sent from the service. */
}
}
else
{
if (qr.Query.ElementType == typeof(Customer))
{
//process customers
foreach (Customer c in qr){ /*process the customer*/ }
// the DataServiceContext does not materialize, resolve
// identity on Customer until it is enumerated.
}
else if (qr.Query.ElementType == typeof(Category))
{
// Process categories.
foreach (Category cat in qr)
{
/*process the category*/
}
// the DataServiceContext does not materialize or
// resolve identity on the Category until
// it is enumerated.
// This means that instream errors will be thrown
// during iteration.
}
}
}
}
catch (DataServiceRequestException e)
{
// This error is thrown if the data service returns with
// a response code < 200 or >299 or the top level element.
// If neither of the above or true, this exception is not
// thrown.
dsr = e.Response;
if (dsr.IsBatchResponse)
{
/*inspect HTTP artifacts associated with the entire batch:
dsr.BatchHeaders, dsr.BatchStatusCode*/
}
/* There will always only be one of these because if the top level
status code was >=200 and =<299 and the first element was not an
error, the call to start the query will not throw. */
foreach (QueryOperationResponse qr in dsr)
{
if (qr.Error != null)
{
// Process error.
}
}
}
설명
데이터 서비스에 일괄 처리로 제출된 쿼리 그룹에서 쿼리는 인스턴스로 DataServiceRequest<TElement> 지정됩니다. 일괄 처리 요청의 응답을 전체적으로 나타내는 A DataServiceResponse 가 반환됩니다. 개별 쿼리 응답은 인스턴스를 열거하여 DataServiceResponse 액세스할 수 있는 개체로 QueryOperationResponseOperationResponse표시됩니다.
생성자
| Name | Description |
|---|---|
| DataServiceRequest<TElement>(Uri) |
DataServiceRequest<TElement> 클래스의 새 인스턴스를 초기화합니다. |
속성
| Name | Description |
|---|---|
| ElementType |
인스턴스를 만드는 데 사용되는 개체의 형식을 DataServiceRequest<TElement> 가져옵니다. |
| RequestUri |
요청 문자열을 포함하는 URI 개체를 가져옵니다. |
메서드
| Name | Description |
|---|---|
| Equals(Object) |
지정한 개체와 현재 개체가 같은지 여부를 확인합니다. (다음에서 상속됨 Object) |
| GetHashCode() |
기본 해시 함수로 작동합니다. (다음에서 상속됨 Object) |
| GetType() |
현재 인스턴스의 Type 가져옵니다. (다음에서 상속됨 Object) |
| MemberwiseClone() |
현재 Object단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
| ToString() |
데이터 서비스에 대한 쿼리의 URI를 나타냅니다. (다음에서 상속됨 DataServiceRequest) |