ChangeOperationResponse 클래스

정의

SaveChanges() 클래스에서 반환된 작업 응답을 열거할 때 DataServiceResponse를 호출한 후에 반환되는 결과입니다.

public ref class ChangeOperationResponse sealed : System::Data::Services::Client::OperationResponse
public sealed class ChangeOperationResponse : System.Data.Services.Client.OperationResponse
type ChangeOperationResponse = class
    inherit OperationResponse
Public NotInheritable Class ChangeOperationResponse
Inherits OperationResponse
상속
ChangeOperationResponse

예제

다음 코드에서는 SaveChanges 호출 결과를 처리하는 방법을 보여 줍니다.

DataServiceContext service = new DataServiceContext(new Uri("http://myserviceroot"));  

// Do insert, update, delete, or attach operations.  

DataServiceResponse dsr;  

try  
{  
    dsr = service.SaveChanges(SaveChangesOptions.Batch);    
   // Or service.SaveChanges(SaveChangesOptions.ContinueOnError);   
   //Or service.SaveChanges();  
   // If there are no errors during save changes, process the results:  

    if (dsr.IsBatchResponse)  
    {  
           /*inspect HTTP artifacts associated with the entire batch:  
                             dsr.BatchHeaders, dsr.BatchStatusCode*/ }  

    foreach (ChangeOperationResponse cor in dsr)  
    {  

            if (cor.Descriptor is EntityDescriptor)  
            {  
                EntityDescriptor ed = (EntityDescriptor)cor.Descriptor;  
                // This should be the case if  
                // SaveChanges did not throw an exception.    

                // After an entity is processed by SaveChanges,  
                // it is always moved to the unchanged state.  
                System.Diagnostics.Debug.Assert(  
                           ed.State == EntityStates.Unchanged);    
                // This shows that the state should be unchanged if  
                // the result is success.  

                //process the entity in the response payload: ed.Entity  
            }  
            else if (cor.Descriptor is LinkDescriptor)  
            {  
                LinkDescriptor ld = (LinkDescriptor)cor.Descriptor;  
               // This should be the case if SaveChanges did not throw an exception.  

               // After an entity is processed by SaveChanges it  
               // is always moved to the unchanged state.  
                System.Diagnostics.Debug.Assert(  
                            ld.State == EntityStates.Unchanged);    
                // The state should be unchanged if the result is success.  

                //process the link in the response payload: ld.Source,  
                // ld.SourceProperty, or ld.Target.  
            }  
     }  

}  
catch (DataServiceSaveException se)  
{  
    // Error while saving changes  
    dsr = se.Response;  

    if (dsr.IsBatchResponse)   
    {   
        /*inspect HTTP artifacts associated with the entire batch:  
             dsr.BatchHeaders, dsr.BatchStatusCode*/   
}      
}  

    foreach (ChangeOperationResponse cor in dsr)  
    {  
        if (cor.Error != null)  
        {  
            //process error  
        }  
        else  
        {  
            // same success case processing as in the loop over DSRs results in   
            // the try block. You could put that processing in a method   
            // and call it from here.      
        }  
    }  

}  

 catch(Exception)  
 {  
    // Error while saving changes, but not thrown by the client library.  

    // Process ArgumentException, InvalidOperationException, or similar.  
}  
}  

설명

ChangeOperationResponse 개체는 이 라이브러리의 사용자가 직접 생성할 수 없습니다. 대신, DataServiceResponse 클래스의 열거자를 통해 반환된 작업 응답을 열거할 때 참조가 반환됩니다.

SaveChangesDataServiceContext가 마지막으로 호출된 후 SaveChanges에서 수집된 보류 중인 변경 내용을 데이터 서비스에 전송합니다. 변경 내용은 AddObject, AddLink, DeleteObject, DeleteLink, Detach, DetachLink 및 유사 메서드를 호출하면 컨텍스트에 추가됩니다.

SaveChanges는 데이터 서비스에 전송된 모든 작업에 대한 응답을 나타내는 DataServiceResponse를 반환합니다. DataServiceResponse 개체는 유지되거나 시도된 변경 내용을 나타내는 ChangeOperationResponse 또는 EntityDescriptor 인스턴스의 시퀀스가 차례로 포함되는 LinkDescriptor 개체의 시퀀스를 포함합니다.

속성

Descriptor

변경 작업에 의해 수정된 EntityDescriptor 또는 LinkDescriptor를 가져옵니다.

Error

작업에서 throw된 오류를 가져옵니다.

(다음에서 상속됨 OperationResponse)
Headers

파생 클래스에서 재정의된 경우 단일 작업과 연관된 HTTP 응답 헤더를 포함합니다.

(다음에서 상속됨 OperationResponse)
StatusCode

파생 클래스에서 재정의된 경우 단일 작업과 연관된 HTTP 응답 코드를 가져오거나 설정합니다.

(다음에서 상속됨 OperationResponse)

메서드

Equals(Object)

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

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

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

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

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

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

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

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

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상