TableServiceContext.SaveChangesWithRetries Method ()

Storage Client Library NET API

[This topic is part of the Microsoft Azure Storage Client Library 1.7, which has been deprecated. See Storage Client Library for the latest version.]

Saves changes to the Table service, using the retry policy specified for the TableServiceContext object.

Namespace: Microsoft.WindowsAzure.StorageClient
Assembly: Microsoft.WindowsAzure.StorageClient (in Microsoft.WindowsAzure.StorageClient.dll)

Usage

Visual Basic
Dim instance As TableServiceContext
Dim returnValue As DataServiceResponse

returnValue = instance.SaveChangesWithRetries

Syntax

Visual Basic
Public Function SaveChangesWithRetries As DataServiceResponse
C#
public DataServiceResponse SaveChangesWithRetries ()
C++
public:
DataServiceResponse^ SaveChangesWithRetries ()
J#
JScript

Return Value

Type: System.Data.Services.Client.DataServiceResponse

A DataServiceResponse that represents the result of the operation.

Example

The following code example inserts an entity into a table.

 Copy Code
public static void InsertContact(CloudTableClient tableClient, string firstName, string lastName, string email,
    string cellPhone, string homePhone, string streetAddress, string city, string state, string zipCode)
{
    // Get data context.
    TableServiceContext context = tableClient.GetDataServiceContext();

    // Create the new entity.
    ContactEntity entity = new ContactEntity();

    // Partition key is first letter of contact's first name.
    entity.PartitionKey = firstName.Substring(0, 1).ToUpper();

    // Row key is value of first name, with GUID appended to avoid conflicts in case where two first names are the same.
    entity.RowKey = firstName + "_" + Guid.NewGuid().ToString();

    // Populate the other properties.
    entity.FirstName = firstName;
    entity.LastName = lastName;
    entity.Email = email;
    entity.CellPhone = cellPhone;
    entity.HomePhone = homePhone;
    entity.StreetAddress = streetAddress;
    entity.City = city;
    entity.State = state;
    entity.ZipCode = zipCode;

    // Add the entity.
    context.AddObject(tableName, entity);

    // Save changes to the service.
    context.SaveChangesWithRetries();
}

public class ContactEntity : TableServiceEntity
{
    public ContactEntity()
    {
    }

    public string FirstName { get; set; }
    public string LastName { get; set; }
    public string Email { get; set; }
    public string HomePhone { get; set; }
    public string CellPhone { get; set; }
    public string StreetAddress { get; set; }
    public string City { get; set; }
    public string State { get; set; }
    public string ZipCode { get; set; }
}

Remarks

The SaveChangesWithRetries method behaves in the same manner as the SaveChanges method, with the addition of retries as specified by the RetryPolicy property.


Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

Windows Vista, Windows 7, Windows Server 2008, Windows 8.1, Windows Server 2012 R2, Windows 8 and Windows Server 2012

Change History

See Also