Line data Source code
1 : #region Copyright
2 : // // -----------------------------------------------------------------------
3 : // // <copyright company="Chinchilla Software Limited">
4 : // // Copyright Chinchilla Software Limited. All rights reserved.
5 : // // </copyright>
6 : // // -----------------------------------------------------------------------
7 : #endregion
8 :
9 : using System;
10 : using System.Collections.Generic;
11 : using System.Linq;
12 : using Cqrs.DataStores;
13 : using Cqrs.Entities;
14 : using Microsoft.WindowsAzure.Storage.Table;
15 :
16 : namespace Cqrs.Azure.BlobStorage
17 : {
18 : /// <summary>
19 : /// Extension methods for Azure Table storage.
20 : /// </summary>
21 : public static class TableStorageStoreExtensions
22 1 : {
23 : /// <summary>
24 : /// Retrieves the data from Azure Storage by it's <see cref="TableEntity.PartitionKey"/> and <see cref="TableEntity.RowKey"/>.
25 : /// </summary>
26 1 : public static TData GetByKeyAndRow<TData>(this IDataStore<TData> datastore, Guid rsn)
27 : where TData : IEntity
28 : {
29 : var rawDatastore = (TableStorageStore<EntityTableEntity<TData>, TData>)datastore;
30 : return rawDatastore.GetByKeyAndRow(rsn).Entity;
31 : }
32 :
33 : /// <summary>
34 : /// Retrieves the data from Azure Storage by it's <see cref="TableEntity.PartitionKey"/>.
35 : /// </summary>
36 1 : public static IEnumerable<TData> GetByKey<TData>(this IDataStore<TData> datastore)
37 : where TData : IEntity
38 : {
39 : var rawDatastore = (TableStorageStore<EntityTableEntity<TData>, TData>)datastore;
40 : return rawDatastore.GetByKey().Select(entity => entity.Entity);
41 : }
42 : }
43 : }
|