[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)
Usage
Visual Basic |
---|
Dim instance As CloudTableClient
Dim returnValue As TableServiceContext
returnValue = instance.GetDataServiceContext |
Syntax
Visual Basic |
---|
Public Function GetDataServiceContext As TableServiceContext |
C# |
---|
public TableServiceContext GetDataServiceContext () |
C++ |
---|
public:
TableServiceContext^ GetDataServiceContext () |
Return Value
Type:
Microsoft.WindowsAzure.StorageClient.TableServiceContextThe runtime context to use for performing data operations against the Table service.
Example
The following code example gets an entity from a table and deletes it.
C# | Copy Code |
---|
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; }
}
|
Remarks
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
Change History
See Also