ChangeOperationResponse Sınıf

Tanım

Sınıfı tarafından döndürülen işlem yanıtlarını numaralandırırken çağrısından SaveChanges()DataServiceResponse sonra döndürülen sonuçlar.

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
Devralma
ChangeOperationResponse

Örnekler

Aşağıdaki kod, çağrısının SaveChangessonuçlarının nasıl işlendiği gösterir.

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.
}
}

Açıklamalar

ChangeOperationResponse nesneleri doğrudan bu kitaplığın bir kullanıcısı tarafından oluşturulacak şekilde tasarlanmamıştır. Bunun yerine, başvurular, sınıfındaki numaralandırıcı aracılığıyla döndürülen işlem yanıtları numaralandırılırken DataServiceResponse döndürülür.

SaveChangesson çağrısından DataServiceContextbu yana tarafından SaveChanges toplanan veri hizmetinde bekleyen değişiklikleri gönderir. Değişiklikler , , , AddObject, AddLinkDeleteObjectDeleteLinkDetachve benzer yöntemler çağrılarak DetachLinkbağlama eklenir.

SaveChanges , veri hizmetine gönderilen tüm işlemlere verilen yanıtı temsil eden bir DataServiceResponse döndürür. nesnesiDataServiceResponse, kalıcı veya denenen değişiklikleri temsil eden veya ChangeOperationResponse örnekleri içeren bir dizi EntityDescriptor nesne içerirLinkDescriptor.

Özellikler

Name Description
Descriptor

EntityDescriptor LinkDescriptor Veya değerini bir değişiklik işlemiyle değiştirir.

Error

İşlemin oluşturduğu hatayı alır.

(Devralındığı yer: OperationResponse)
Headers

Türetilmiş bir sınıfta geçersiz kılındığında, tek bir işlemle ilişkili HTTP yanıt üst bilgilerini içerir.

(Devralındığı yer: OperationResponse)
StatusCode

Türetilmiş bir sınıfta geçersiz kılındığında, tek bir işlemle ilişkili HTTP yanıt kodunu alır veya ayarlar.

(Devralındığı yer: OperationResponse)

Yöntemler

Name Description
Equals(Object)

Belirtilen nesnenin geçerli nesneye eşit olup olmadığını belirler.

(Devralındığı yer: Object)
GetHashCode()

Varsayılan karma işlevi işlevi görür.

(Devralındığı yer: Object)
GetType()

Geçerli örneğin Type alır.

(Devralındığı yer: Object)
MemberwiseClone()

Geçerli Objectbasit bir kopyasını oluşturur.

(Devralındığı yer: Object)
ToString()

Geçerli nesneyi temsil eden bir dize döndürür.

(Devralındığı yer: Object)

Şunlara uygulanır