DataServiceRequest<TElement> 클래스

정의

일괄 처리로 데이터 서비스에 제출된 요청 개체를 나타냅니다.

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
상속
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> 인스턴스로 지정됩니다. DataServiceResponse는 전체 일괄 처리 요청의 응답을 나타내도록 반환됩니다. 개별 쿼리 응답은 QueryOperationResponse에서 파생된 OperationResponse 개체로 표현되며 DataServiceResponse 인스턴스를 열거하여 액세스할 수 있습니다.

생성자

DataServiceRequest<TElement>(Uri)

DataServiceRequest<TElement> 클래스의 새 인스턴스를 초기화합니다.

속성

ElementType

DataServiceRequest<TElement> 인스턴스를 만드는 데 사용되는 개체의 형식을 가져옵니다.

RequestUri

요청 문자열을 포함하는 URI 개체를 가져옵니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

데이터 서비스에 대한 쿼리의 URI를 나타냅니다.

(다음에서 상속됨 DataServiceRequest)

적용 대상