ChangeOperationResponse 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
클래스에서 반환된 작업 응답을 열거할 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
- 상속
예제
다음 코드에서는 호출 결과를 처리하는 방법을 보여 있습니다 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 반환됩니다.
SaveChanges 는 마지막 호출 이후 수집된 DataServiceContext 데이터 서비스에 보류 중인 변경 내용을 제출합니다 SaveChanges. 변경 내용은 , , DeleteObjectAddLink, DetachDetachLinkDeleteLink및 유사한 메서드를 호출AddObject하여 컨텍스트에 추가됩니다.
속성
| Name | Description |
|---|---|
| Descriptor |
EntityDescriptor LinkDescriptor 변경 작업에 의해 수정된 값을 가져옵니다. |
| Error |
작업에 의해 throw된 오류를 가져옵니다. (다음에서 상속됨 OperationResponse) |
| Headers |
파생 클래스에서 재정의되는 경우 단일 작업과 연결된 HTTP 응답 헤더를 포함합니다. (다음에서 상속됨 OperationResponse) |
| StatusCode |
파생 클래스에서 재정의되는 경우 단일 작업과 연결된 HTTP 응답 코드를 가져오거나 설정합니다. (다음에서 상속됨 OperationResponse) |
메서드
| Name | Description |
|---|---|
| Equals(Object) |
지정한 개체와 현재 개체가 같은지 여부를 확인합니다. (다음에서 상속됨 Object) |
| GetHashCode() |
기본 해시 함수로 작동합니다. (다음에서 상속됨 Object) |
| GetType() |
현재 인스턴스의 Type 가져옵니다. (다음에서 상속됨 Object) |
| MemberwiseClone() |
현재 Object단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
| ToString() |
현재 개체를 나타내는 문자열을 반환합니다. (다음에서 상속됨 Object) |