本文整理匯總了C#中Microsoft.WindowsAzure.Storage.Table.CloudTable.Exists方法的典型用法代碼示例。如果您正苦於以下問題:C# CloudTable.Exists方法的具體用法?C# CloudTable.Exists怎麽用?C# CloudTable.Exists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Microsoft.WindowsAzure.Storage.Table.CloudTable
的用法示例。
在下文中一共展示了CloudTable.Exists方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: PopulateTableData
private static void PopulateTableData(CloudTable cloudTable)
{
// if the table does not exist then create it and populate it wih some data
if (!cloudTable.Exists())
{
cloudTable.CreateIfNotExists();
var tableBatchOperation = new TableBatchOperation();
for (int i = 0; i < 100; i++)
{
tableBatchOperation.Add(
TableOperation.Insert(new Person(i.ToString(), string.Format("Person {0}", i))));
}
cloudTable.ExecuteBatch(tableBatchOperation);
}
}
示例2: CloudDal
public CloudDal()
{
// Retrieve the storage account from the connection string.
CloudStorageAccount storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
// Create the table client.
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
// Create the table if it doesn't exist.
table = tableClient.GetTableReference("people");
if (table.Exists()==false)
{
table.Create();
}
}
示例3: DoesTableExist
/// <summary>
/// Checks whether the table exists.
/// </summary>
/// <param name="table">Cloud table object</param>
/// <param name="requestOptions">Table request options</param>
/// <param name="operationContext">Operation context</param>
/// <returns>True if table exists; otherwise, false.</returns>
public bool DoesTableExist(CloudTable table, TableRequestOptions requestOptions, OperationContext operationContext)
{
return table.Exists(requestOptions, operationContext);
}
示例4: DeleteEntities
public void DeleteEntities(CloudTable table, string partition = null)
{
if (!table.Exists())
{
return;
}
TableQuery query = new TableQuery();
if (partition != null)
{
query.FilterString = string.Format("PartitionKey eq '{0}'", partition);
}
var entities = table.ExecuteQuery(query);
if (entities.Any())
{
var batch = new TableBatchOperation();
foreach (var entity in entities)
{
batch.Delete(entity);
}
table.ExecuteBatch(batch);
}
}