天下网吧 >> 网吧天地 >> 网吧技术 >> 网吧软件 >> 正文

如何在Windows Azure存储中备份模拟运算表

2010-5-18不详佚名

      BackupTableRange建立了一个会扫描指定密钥范围的查询,然后援引下列BackupToContainer。我们使用BackupEntity类来读取结果。BackupEntity保存了一个内部XElement,XElement名为EntryElement,它将接收到的一个用于实体数据的原始OData XML保存在查询响应中。为了掌握这个原始数据,我们可以使用所示代码中的ReadingEntity事件。ResolveType代表用来提供类型名称,而WCF数据服务客户会使用此类型名称。 /// <summary> /// Create a query that will scan the assigned range and save it to a blob in the given container /// </summary> /// <param name="tableClient"></param> /// <param name="container"></param> /// <param name="tableName"></param> /// <param name="range"></param> /// <param name="backupId"></param> private static void BackupTableRange( CloudTableClient tableClient, CloudBlobContainer container, string tableName, PartitionKeyRange range, string backupId) {         TableServiceContext context = tableClient.GetDataServiceContext();         context.MergeOption = MergeOption.NoTracking;         context.ResolveType = TableBackup.ResolveType;         context.ReadingEntity += new EventHandler<ReadingWritingEntityEventArgs>(TableBackup.OnReadingEntity);         context.RetryPolicy = RetryPolicies.RetryExponential(5, RetryPolicies.DefaultClientBackoff);                 var query = from entity in context.CreateQuery<BackupEntity>(tableName) select entity;         if (range.Min != null)         {             query = query.Where(entity => entity.PartitionKey.CompareTo(range.Min) >= 0);         }           if (range.Max != null)         {             query = query.Where(entity => entity.PartitionKey.CompareTo(range.Max) < 0);         }                 CloudTableQuery<BackupEntity> cloudQuery = new CloudTableQuery<BackupEntity>((DataServiceQuery<BackupEntity>)query);           BackupToContainer(container, cloudQuery, backupId, range); }   /// <summary> /// Entities used for backup/restore /// </summary> [DataServiceKey("PartitionKey", "RowKey")] public class BackupEntity {     public string PartitionKey { get; set; }       public string RowKey { get; set; }       /// <summary>     /// Used during restore to store the entry element.     /// </summary>     internal XElement EntryElement { get; set; } }   static void OnReadingEntity(object sender, ReadingWritingEntityEventArgs args) {      BackupEntity entity = args.Entity as BackupEntity;      entity.EntryElement = args.Data; }   static Type ResolveType(string entityName) {         return typeof(BackupEntity); }

9 7 3 1 2 3 4 5 6 4 8 :

本文来源:不详 作者:佚名

声明
声明:本站所发表的文章、评论及图片仅代表作者本人观点,与本站立场无关。文章是出于传递更多信息之目的。若有来源标注错误或侵犯了您的合法权益,请作者持权属证明与本网联系,我们将及时更正、删除,谢谢。 Email:support@txwb.com,系统开号,技术支持,服务联系微信:_WX_1_本站所有有注明来源为天下网吧或天下网吧论坛的原创作品,各位转载时请注明来源链接!
天下网吧·网吧天下
  • 本周热门
  • 本月热门
  • 阅读排行