本文整理汇总了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);
}
}