WindowsAzure:.NET库旨在管理和查询Windows Azure存储中的实体。 可用作LINQ到Azure表

  • d7_286834
    了解作者
  • 184.3KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-10 18:34
    上传日期
Windows Azure存储扩展 信息 版本 依存关系 信息 Microsoft已声明不推荐使用此依赖项。 这仍然是预览版本。 Windows Azure存储扩展是一个.NET库,旨在管理和查询实体。 它基于构建,通过使用POCO实体通过TableSet上下文为Azure表查询提供异步接口()和LINQ 。 目录 特征 属性映射 POCO属性和字段应使用PartitionKey和RowKey属性之一或两者进行标记,以定义组合表键。 也可以使用Timestamp , ETag , Property和Ignore属性。 流利的映射 流利的映射是同名映射样式,我们可以使用它来替代AttributeMapping。 它是一个流畅的界面,使您可以在代码中完全映射实体,并带来所有编译时的安全性和可重构性。 EntityTypeMap类 EntityTypeMap类是所有映射的基础,您可
WindowsAzure-master.zip
内容介绍
# Windows Azure Storage Extensions [<img src="http://teamcity.jetbrains.com/app/rest/builds/buildType:(id:wase_general),branch:(name:master)/statusIcon.svg"/>](http://teamcity.jetbrains.com/viewType.html?buildTypeId=wase_general&branch_WindowsAzureStorageExtensions=%3Cdefault%3E&guest=1) ## Info | Version | Dependencies | Information | :--- | :--- | :--- [![WindowsAzure.StorageExtensions](https://buildstats.info/nuget/WindowsAzure.StorageExtensions)](https://www.nuget.org/packages/WindowsAzure.StorageExtensions) | [Windows.Azure.Storage](https://www.nuget.org/packages/WindowsAzure.Storage/) | This dependency is declared deprecated by Microsoft. [![MicrosoftAzureCosmos.TableExtensions](https://buildstats.info/nuget/MicrosoftAzureCosmosTable.Extensions)](https://www.nuget.org/packages/MicrosoftAzureCosmosTable.Extensions) | [Microsoft.Azure.Cosmos.Table](https://www.nuget.org/packages/Microsoft.Azure.Cosmos.Table/1.0.7) | [![V2-preview](https://img.shields.io/badge/nuget-v2.0.0_preview_00-blue)](https://www.nuget.org/packages/MicrosoftAzureCosmosTable.Extensions) | [Microsoft.Azure.Cosmos.Table - Preview](https://www.nuget.org/packages/Microsoft.Azure.Cosmos.Table/2.0.0-preview) | This is still a preview version. *Windows Azure Storage Extensions* is a .NET library aimed at managing and querying entities from [Azure Storage Tables](http://msdn.microsoft.com/en-us/library/windowsazure/dd179463.aspx). It's built on top of the **[Azure .NET SDK](https://github.com/WindowsAzure/azure-sdk-for-net)**, provides **async interfaces** ([Task-based Asynchronous Pattern](http://msdn.microsoft.com/en-us/library/hh873175.aspx)) and **LINQ to Azure Table** queries via `TableSet` context by using **POCO** entities. ## Table Of Contents * [Features](#features) * [Code Samples](#code-samples) * [Sponsors](#sponsors) ## Features ### Attribute Mapping POCO properties and fields should be marked by one or both of `PartitionKey` and `RowKey` attributes for defining composite table key. Also can be used `Timestamp`, `ETag`, `Property` and `Ignore` attributes. ### Fluent Mapping Fluent mapping is the namesake mapping style that we use as an alternative to the AttributeMapping. It's a fluent interface that allows you to map your entities completely in code, with all the compile-time safety and refactorability that brings. #### EntityTypeMap class <code>EntityTypeMap<T></code> class is the basis of all your mappings, you derive from this to map anything. ``` c# public class AddressMap : EntityTypeMap<address rel='nofollow' onclick='return false;'> { public AddressMap() { this.PartitionKey(p => p.CountryCode) .RowKey(p => p.Id) .Ignore(p => c.Country); } } ``` You map your entities properties inside the constructor. > **Syntax note:** Every mapping inside a <code>EntityTypeMap<T></code> is built using lambda expressions, which allow us to reference the properties on your entities without sacrificing compile-time safety. The lambdas typically take the form of <code>x => x.Property</code>. The <code>x</code> on the left is the parameter declaration, which will implicitly be of the same type as the entity being mapped, while the <code>x.Property</code> is accessing a property on your entity (coincidentally called "Property" in this case). Once you've declared your <code>EntityTypeMap<T></code> you're going to need to map the properties on your entity. There are several methods available that map your properties in different ways, and each one of those is a [chainable method](http://martinfowler.com/dslwip/MethodChaining.html) that you can use to customise the individual mapping. ##### PartitionKey and RowKey Every mapping requires an `PartitionKey` and `RowKey` of some kind. The PartitionKey is mapped using the <code>PartitionKey</code> method, which takes a lambda expression that accesses the property on your entity that will be used for the PartitionKey. PartitionKey(x => x.MyPartitionKeyProperty); The PartitionKey is mapped using the <code>RowKey</code> method, which takes a lambda expression that accesses the property on your entity that will be used for the PartitionKey. RowKey(x => x.MyRowKeyProperty); ##### Ignore If you need to ignore a property by using the <code>Ignore</code> method, which takes a lambda expression that accesses the property on your entity that will ignored by the serializer. Ignore(x => x.MyPropertyToIgnore); ##### ETag and Timestamp The `ETag` property is mapped using the methods <code>ETag</code>, which takes a lambda expression that accesses the property on your entity that will be mapped. ETag(x => x.MyETagProperty); The `Timestamp` property is mapped using the methods <code>Timestamp</code>, which takes a lambda expression that accesses the property on your entity that will be mapped. Timestamp(x => x.MyTimestampProperty); #### Register custom mapping assembly The `TableEntityConverter` class will try to find the mapping classes for your entities on the same assembly of the entitie, if you are using a different assembly for mappings classes you'll need to register this assembly by using the <code>RegisterAssembly</code> method from class <code>EntityTypeMap</code>. **ATTENTION: this method just need to be called once and before instantiating the <code>TableSet</code> class**. Below there is a sample of how we call the EntityTypeMap.RegisterAssembly(typeof(MyEntity).Assembly) ### Entities Management Generic `TableSet` context provides a synchronous & asynchronous ([TAP](http://msdn.microsoft.com/en-us/library/hh873175.aspx)) methods for managing entities: * *Synchronous*: Add, AddOrUpdate, Update and Remove. * *Asynchronous*: AddAsync, AddOrUpdateAsync, UpdateAsync and RemoveAsync. To avoid [restrictions of group operations](http://msdn.microsoft.com/en-us/library/windowsazure/dd894038.aspx) in Azure Storage all entities sorted by partition keys and merged into groups by 100 entities. Execution of requests with such batch operations can be configured via TableSet's `ExecutionMode` property. Allowed values: * Sequential * Parallel Default ExecutionMode is Sequential. ### LINQ Queries `TableSet` context implements `IQueryable` interface for using [LINQ Expressions](http://msdn.microsoft.com/en-us/library/vstudio/bb397926.aspx). Provider supports next synchronous LINQ methods: * First * FirstOrDefault * Single * SingleOrDefault * Take * Where To utilize [filtering capabilities of string properties](http://msdn.microsoft.com/en-us/library/windowsazure/dd894031.aspx) it supports: * [Compare](http://msdn.microsoft.com/en-us/library/84787k22.aspx) * [CompareTo](http://msdn.microsoft.com/en-us/library/fkw3h78a.aspx) * [CompareOrdinal](http://msdn.microsoft.com/en-us/library/af26w0wa.aspx) Also you can use [**Contains** method](http://msdn.microsoft.com/en-us/library/ms132407.aspx). In this case query statement for each collection's item will be joined by using OData _or_ operator. **NOTE**: For creating a custom queries you should take a look at next article: [Mixing LINQ Providers and LINQ to Objects](http://msdn.microsoft.com/en-us/vstudio/ff963710.aspx). ### Asynchronous LINQ Queries In addition `TableSet` can be used for **asynchronous queries** powered by LINQ extensions (TAP) in [EF 6 Async style](http://weblogs.asp.net/scottgu/archive/2012/12/11/entity-framework-6-alpha2-now-available.aspx). Available methods: * FirstAsync * FirstOrDefaultAsync * SingleAsync * SingleOrDefaultAsync * TakeAsync * ToListAsync ### LINQ Projections LINQ Projections supported with a limitation - projection class should be a reference type. ### TAP-based Extensions Library contains TAP-based extensions for following Azure Storage Library classes: * CloudBlobClient * CloudBlobContainer * CloudTableClient * CloudTable To use it just add _Async_ postfix to
评论
    相关推荐