本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Table.CloudTable.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# CloudTable.Execute方法的具体用法?C# CloudTable.Execute怎么用?C# CloudTable.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.WindowsAzure.Storage.Table.CloudTable
的用法示例。
在下文中一共展示了CloudTable.Execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public virtual void Init()
{
var client = CloudStorageAccount.DevelopmentStorageAccount.CreateCloudTableClient();
_table = client.GetTableReference("kalixleotablequery");
_table.CreateIfNotExists();
_table.Execute(TableOperation.InsertOrReplace(BuildEntity("test1", "test1")));
_table.Execute(TableOperation.InsertOrReplace(BuildEntity("test1", "test2")));
_table.Execute(TableOperation.InsertOrReplace(BuildEntity("test2", "test1")));
_table.Execute(TableOperation.InsertOrReplace(BuildEntity("test2", "test2")));
_query = new AzureTableQuery<TestEntity>(_table, null);
}
示例2: CopyEntity
private void CopyEntity(DynamicTableEntity entity, CloudTable destTable)
{
ConsoleWrite.Verbose(" Copying {0} / {1}", entity.PartitionKey, entity.RowKey);
if (_args.IsReal)
{
var operation = TableOperation.Insert(entity);
destTable.Execute(operation);
}
}
示例3: InsertSession
private static void InsertSession(CloudTable table)
{
//Create some data to store
var session = CreateSession();
// Create the TableOperation object that inserts the session entity.
var insertOperation = TableOperation.Insert(session);
// Execute the insert operation.
table.Execute(insertOperation);
}
示例4: LookupAsync
// Used to fetch an existing container entry so we can append it.
public static Task<ContainerActiveEntity> LookupAsync(CloudTable table, long timeBucket, string containerName)
{
TableOperation retrieveOperation = TableOperation.Retrieve<ContainerActiveEntity>(
TableScheme.ContainerActivePK,
RowKeyTimeInterval(timeBucket, containerName));
// Execute the retrieve operation.
TableResult retrievedResult = table.Execute(retrieveOperation);
var x = (ContainerActiveEntity)retrievedResult.Result;
return Task.FromResult(x);
}
示例5: Search2
private static void Search2(CloudTable table)
{
TableOperation retrieveOperation = TableOperation.Retrieve<CustomerEntity>("Harp", "Ben");
// Execute the retrieve operation.
TableResult retrievedResult = table.Execute(retrieveOperation);
// Print the phone number of the result.
if (retrievedResult.Result != null)
Console.WriteLine(((CustomerEntity)retrievedResult.Result).PhoneNumber);
else
Console.WriteLine("The phone number could not be retrieved.");
}
示例6: DashboardUpdate
public DashboardUpdate(CloudTable generalInfoTable, CloudTable pageTable, CloudTable errorTable, CloudTable mappingTable, CloudQueue urlQ)
{
this.dashboardTable = generalInfoTable;
this.pageTable = pageTable;
this.errorTable = errorTable;
this.mappingTable = mappingTable;
this.urlQ = urlQ;
IEnumerator<Dashboard> results = generalInfoTable.ExecuteQuery(new TableQuery<Dashboard>()).GetEnumerator();
if (!results.MoveNext())
{
generalInfoTable.Execute(TableOperation.InsertOrReplace(new Dashboard(0, 0, 0, new List<string>(), new List<string>())));
}
}
示例7: Setup
public void Setup()
{
this.storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
this.tableClient = storageAccount.CreateCloudTableClient();
this.table1 = tableClient.GetTableReference("table1");
this.table1.DeleteIfExists();
this.table1.Create();
var entityToCreate = new TestEntity()
{
ID = "1",
FirstName = "Cecil",
LastName = "Cedar"
};
entityToCreate.PartitionKey = entityToCreate.LastName;
entityToCreate.RowKey = entityToCreate.ID;
var op = TableOperation.Insert(entityToCreate);
table1.Execute(op);
}
示例8: Initialize
public static void Initialize(TestContext context)
{
ConnectionStringSettingsCollection settings =
ConfigurationManager.ConnectionStrings;
ConnectionStringSettings connectionStringSettings = settings["Azure"];
var builder = new DbConnectionStringBuilder
{
ConnectionString = connectionStringSettings.ConnectionString
};
accountName = (string) builder["AccountName"];
accountKey = (string) builder["AccountKey"];
var account = CloudStorageAccount.Parse(connectionStringSettings.ConnectionString);
CloudTableClient tableClient = account.CreateCloudTableClient();
// Create Table
table = tableClient.GetTableReference(TableName);
var b = table.DeleteIfExists();
Console.WriteLine(string.Format("deleted table {0}: {1}", TableName, b));
table.CreateIfNotExists();
// Insert Entity
var person = new ContactEntity("Peter", "Ritchie") { Email = "[email protected]", PhoneNumber = "555-0123" };
table.Execute(TableOperation.Insert(person));
}
示例9: TableUpdateSasTestSync
public void TableUpdateSasTestSync()
{
CloudTableClient tableClient = GenerateCloudTableClient();
CloudTable table = tableClient.GetTableReference("T" + Guid.NewGuid().ToString("N"));
try
{
table.Create();
BaseEntity entity = new BaseEntity("PK", "RK");
table.Execute(TableOperation.Insert(entity));
SharedAccessTablePolicy policy = new SharedAccessTablePolicy()
{
SharedAccessStartTime = DateTimeOffset.UtcNow.AddMinutes(-5),
SharedAccessExpiryTime = DateTimeOffset.UtcNow.AddMinutes(30),
Permissions = SharedAccessTablePermissions.Delete,
};
string sasToken = table.GetSharedAccessSignature(policy);
StorageCredentials creds = new StorageCredentials(sasToken);
CloudTable sasTable = new CloudTable(table.Uri, creds);
TestHelper.ExpectedException(
() => sasTable.Execute(TableOperation.Insert(new BaseEntity("PK", "RK2"))),
"Try to insert an entity when SAS doesn't allow inserts",
HttpStatusCode.Forbidden);
sasTable.Execute(TableOperation.Delete(entity));
SharedAccessTablePolicy policy2 = new SharedAccessTablePolicy()
{
SharedAccessStartTime = DateTimeOffset.UtcNow.AddMinutes(-5),
SharedAccessExpiryTime = DateTimeOffset.UtcNow.AddMinutes(30),
Permissions = SharedAccessTablePermissions.Delete | SharedAccessTablePermissions.Add,
};
string sasToken2 = table.GetSharedAccessSignature(policy2);
creds.UpdateSASToken(sasToken2);
sasTable = new CloudTable(table.Uri, creds);
sasTable.Execute(TableOperation.Insert(new BaseEntity("PK", "RK2")));
}
finally
{
table.DeleteIfExists();
}
}
示例10: CalculateMADataToAzure
private void CalculateMADataToAzure(CloudTable table, string azureTableStockCode, int MA)
{
DateTime startingDate = DateTime.FromFileTimeUtc(0);
TableOperation retrieveStockEntityStatus = TableOperation.Retrieve<StockEntityStatus>("status-" + azureTableStockCode, "status");
var stockEntityStatus = (StockEntityStatus)table.Execute(retrieveStockEntityStatus).Result;
if (stockEntityStatus != null)
{
startingDate = stockEntityStatus.GetLatestMAStartDate(MA);
Console.WriteLine("Latest starting date for MA{0} is on {1}", MA, startingDate.ToString("yyyy-MM-dd"));
}
string pkFilter = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, azureTableStockCode);
string rkLowerFilter = TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.GreaterThanOrEqual, startingDate.ToString("yyyy-MM-dd"));
string combinedFilter = TableQuery.CombineFilters(pkFilter, TableOperators.And, rkLowerFilter);
TableQuery<StockEntity> query = new TableQuery<StockEntity>().Where(combinedFilter);
var sortedStockEntities = table.ExecuteQuery<StockEntity>(query).OrderBy(entity => entity.Date).ToList();
if (sortedStockEntities.LongCount() >= MA)
{
long totalCountToUpload = sortedStockEntities.LongCount();
long currentCountUploaded = 0;
Queue<double> maData = new Queue<double>();
TableBatchOperation tableBatchOperation = new TableBatchOperation();
foreach (var stockEntity in sortedStockEntities)
{
maData.Enqueue(stockEntity.Close);
if (maData.Count == MA)
{
double sum = 0;
foreach (var data in maData)
{
sum += data;
}
stockEntity.SetMA(MA, sum / MA);
tableBatchOperation.Add(TableOperation.InsertOrMerge(stockEntity));
maData.Dequeue();
}
if (tableBatchOperation.Count == 100)
{
table.ExecuteBatch(tableBatchOperation);
currentCountUploaded += 100;
Console.WriteLine("{0}/{1} entities uploaded...", currentCountUploaded, totalCountToUpload);
tableBatchOperation.Clear();
}
}
if (tableBatchOperation.Count > 0)
{
table.ExecuteBatch(tableBatchOperation);
currentCountUploaded += tableBatchOperation.Count;
Console.WriteLine("{0}/{1} entities uploaded...", currentCountUploaded, totalCountToUpload);
}
sortedStockEntities.Reverse();
if (sortedStockEntities == null)
{
stockEntityStatus = new StockEntityStatus(azureTableStockCode);
}
stockEntityStatus.SetLatestMAStartDate(MA, sortedStockEntities[MA - 2].Date);
table.Execute(TableOperation.InsertOrMerge(stockEntityStatus));
}
}
示例11: CloudTableSASWithAbsoluteUri
public void CloudTableSASWithAbsoluteUri()
{
CloudTableClient tableClient = GenerateCloudTableClient();
CloudTable table = tableClient.GetTableReference(tableClient.BaseUri + GenerateRandomTableName());
try
{
table.CreateIfNotExists();
BaseEntity entity = new BaseEntity("PK", "RK");
table.Execute(TableOperation.Insert(entity));
SharedAccessTablePolicy policy = new SharedAccessTablePolicy()
{
Permissions = SharedAccessTablePermissions.Delete,
SharedAccessStartTime = DateTimeOffset.UtcNow.AddMinutes(-5),
SharedAccessExpiryTime = DateTimeOffset.UtcNow.AddMinutes(10)
};
string sasToken = table.GetSharedAccessSignature(policy);
StorageCredentials creds = new StorageCredentials(sasToken);
CloudTable sasTable = new CloudTable(table.Uri, creds);
sasTable.Execute(TableOperation.Delete(entity));
}
finally
{
table.DeleteIfExists();
}
}
示例12: getWebpageInfo
public PageInfo getWebpageInfo()
{
mappingTable = Azure.GetInstance().getTableReference("mappingtable");
webpageInfo.title = "";
HtmlNode node = root.SelectSingleNode("//title");
if (node != null)
{
webpageInfo.title = node.InnerText;
}
string title = webpageInfo.title;
string[] keywords = title.Split(' ');
try
{
foreach (string keyword in keywords)
{
mappingTable.Execute(TableOperation.Insert(new Mapping(keyword, url)));
}
}
catch (StorageException) { }
string datetime = null;
node = root.SelectSingleNode("//meta[@http-equiv='last-modified']");
if (node != null)
{
datetime = node.GetAttributeValue("content", null);
}
else
{
node = root.SelectSingleNode("//meta[@name='date']");
if (node != null)
{
datetime = node.GetAttributeValue("content", null);
}
else
{
Match match = Regex.Match(html, @"<div>Posted:\s*[^<]+\s*;\s*Updated:\s*([^<]+)\s*</div>");
if (match.Success)
{
datetime = match.Groups[1].Value;
}
else
{
match = Regex.Match(html, @"<div>Posted:\s*([^<]+)\s*</div>");
if (match.Success)
{
datetime = match.Groups[1].Value;
}
}
}
}
try
{
webpageInfo.date = DateTime.Parse(datetime);
}
catch (ArgumentNullException)
{
Trace.TraceInformation("Datetime not fetched for url: " + webpageInfo.url);
throw new WebParseDatetimeException();
}
catch (FormatException)
{
Trace.TraceInformation("Datetime not parsable: " + datetime);
throw new WebParseDatetimeException();
}
return webpageInfo;
}
示例13: InsertEntity
public TableResult InsertEntity(CloudTable table, TableEntity entity)
{
TableOperation insertOperation = TableOperation.Insert(entity);
return table.Execute(insertOperation);
}
示例14: FindExistingLogin
/// <summary>
/// Finds an existing login.
/// </summary>
/// <param name="loginTable">the login table.</param>
/// <param name="accountId">the account id.</param>
/// <returns>A matching entity or null.</returns>
private static LoginEntity FindExistingLogin(
CloudTable loginTable,
EmailAddress accountId)
{
TableOperation findExistingOperation = TableOperation.Retrieve<LoginEntity>(
accountId.Domain,
accountId.LocalPart);
TableResult findExistingResult = loginTable.Execute(findExistingOperation);
return findExistingResult.Result as LoginEntity;
}
示例15: FindExistingOrganization
/// <summary>
/// Finds an existing organization by name.
/// </summary>
/// <param name="table">the organization table.</param>
/// <param name="name">the organization name.</param>
/// <returns>The matching entity or null.</returns>
private static OrganizationEntity FindExistingOrganization(
CloudTable table,
string name)
{
TableOperation findExistingOperation = TableOperation.Retrieve<OrganizationEntity>(
name,
string.Empty);
TableResult findExistingResult = table.Execute(findExistingOperation);
return findExistingResult.Result as OrganizationEntity;
}