Esporta (0) Stampa
Espandi tutto
EN
Il contenuto non è disponibile nella lingua di destinazione, ma solo in inglese.

CloudTableClient.GetDataServiceContext Method

Updated: April 24, 2013

[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.]

Returns a TableServiceContext object for performing data operations against the Table service.

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

'Utilizzo
Dim instance As CloudTableClient
Dim returnValue As TableServiceContext

returnValue = instance.GetDataServiceContext

public TableServiceContext GetDataServiceContext ()

Return Value

Type: Microsoft.WindowsAzure.StorageClient.TableServiceContext

The runtime context to use for performing data operations against the Table service.

The following code example gets an entity from a table and deletes it.


public static void DeleteEntity(CloudStorageAccount storageAccount)
{
    // Create service client for credentialed access to the Table service.
    CloudTableClient tableClient = new CloudTableClient(storageAccount.TableEndpoint.ToString(),
        storageAccount.Credentials);
    // Get the context.
    TableServiceContext context = tableClient.GetDataServiceContext();
    // Get the first entity from the table.
    ProductEntity entity = context.CreateQuery<ProductEntity>("Products").AsTableServiceQuery<ProductEntity>().FirstOrDefault();
    // Delete the entity.
    context.DeleteObject(entity);
    // Save changes to the service.
    context.SaveChanges();
}
// Define a class that represents an entity.
class ProductEntity : TableServiceEntity
{
    public ProductEntity()
    {
    }
    public string ProductName { get; set; }
    public string Category { get; set; }
    public double Price { get; set; }
    public bool InStock { get; set; }
    public DateTime DateAdded { get; set; }
    public Int32 Quantity { get; set; }
}

The Windows Azure TableServiceContext object is derived from the DataServiceContext object provided by the WCF Data Services. This object provides a runtime context for performing data operations against the Table service, including querying entities and inserting, updating, and deleting entities.


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

Development Platforms

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

 

Microsoft sta conducendo un sondaggio in linea per comprendere l'opinione degli utenti in merito al sito Web di MSDN. Se si sceglie di partecipare, quando si lascia il sito Web di MSDN verrà visualizzato il sondaggio in linea.

Si desidera partecipare?
Mostra:
© 2014 Microsoft