Skip to content

veggerby/Veggerby.Azure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Veggerby.Azure

Azure Storage abstractions, based on K. Scott Allen ideas and extended to support Tables, Queues and Blobs.

All methods are async only!

Table Storage

Entity

The Table Storage entity is declared as a normal TableEntity, e.g.

public class FooEntity : TableEntity 
{
	public string Bar { get; set; }
	public int Baz { get; set; }
}

Table Storage

Define your Table Storage:

public class FooEntityStorage : TableStorage<FooEntity>
{
	public FooEntityStorage(string tableName = null, string connectionString = null, StorageInitializeManager storageInitializeManager = null)
        : base(tableName, connectionString, storageInitializeManager)
    {
    }
}

Interfaces

Interface'ify the storage for Dependency Injection:

public interface IFooEntityStorage : ITableStorage<FooEntity>
{
}

public class FooEntityStorage : TableStorage<FooEntity>, IFooEntotyStorage
{
	...
}

Querying

Remember! Querying in Azure Table Storage where not including PartitionKey (and possibly RowKey) has a huge performance impact. For optimal performance queries should include in descending order of performance impact (see MSDN:

  1. PartitionKey (exact) + RowKey (exact)
  2. PartitionKey (exact) + RowKey (partial) + properties
  3. PartitionKey (partial) + RowKey (partial) + properties
  4. Everything else

Querying is done by subclassing StorageQuery

public class ListFooEntityByBarStorageQuery: StorageQuery<FooEntity>
{
	public ListFooEntityByBarStorageQuery(string bar)
	{
		Query = Query.Where(
			TableQuery.GenerateFilterCondition("Bar", QueryComparisons.Equal, bar));
	}
}

Extend the FooEntityStorage class with the List (async) method.

public class FooEntityStorage : TableStorage<FooEntity>
{
	...

	public async Task<IEnumerable<FooEntity>> ListAsync(string bar)
	{
		return await new ListFooEntityByBarStorageQuery(bar).ExecuteOnAsync(Table);
	}
}

Standard Queries

The following queries are implemented by default:

By default the MultiplePartitionStorageQuery, MultipleRowKeysStorageQuery and DateRangeStorageQuery queries are not exposed on the TableStorage class because of the significant performance impact (although this also applies to ListRowsStorageQuery).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages