TableStorage.Abstracts
1.4.2
See the version list below for details.
dotnet add package TableStorage.Abstracts --version 1.4.2
NuGet\Install-Package TableStorage.Abstracts -Version 1.4.2
<PackageReference Include="TableStorage.Abstracts" Version="1.4.2" />
paket add TableStorage.Abstracts --version 1.4.2
#r "nuget: TableStorage.Abstracts, 1.4.2"
// Install TableStorage.Abstracts as a Cake Addin #addin nuget:?package=TableStorage.Abstracts&version=1.4.2 // Install TableStorage.Abstracts as a Cake Tool #tool nuget:?package=TableStorage.Abstracts&version=1.4.2
TableStorage.Abstracts
Azure Table Storage Abstracts library defines abstract base classes for repository pattern.
Download
The TableStorage.Abstracts library is available on nuget.org via package name TableStorage.Abstracts
.
To install TableStorage.Abstracts, run the following command in the Package Manager Console
Install-Package TableStorage.Abstracts
More information about NuGet package available at https://nuget.org/packages/TableStorage.Abstracts
Features
- find one, many and by paged results
- create, update and delete pattern
- batch processing for bulk insert/update
- table initialization on first use
Usage
Dependency Injection
Register services with the Azure storage connection string named 'AzureStorage' loaded from configuration
services.AddTableStorageRepository("AzureStorage");
Example appsettings.json file
{
"AzureStorage": "UseDevelopmentStorage=true"
}
Register with the Azure storage connection string passed in
services.AddTableStorageRepository("UseDevelopmentStorage=true");
Resolve ITableRepository<T>
var repository = serviceProvider.GetRequiredService<ITableRepository<Item>>();
Resolve TableServiceClient
var tableServiceClient = serviceProvider.GetRequiredService<TableServiceClient>();
Custom Repository
Create a custom repository instance by inheriting TableRepository<T>
public class UserRepository : TableRepository<User>
{
public UserRepository(ILoggerFactory logFactory, TableServiceClient tableServiceClient)
: base(logFactory, tableServiceClient)
{ }
protected override void BeforeSave(User entity)
{
// use email as partition key
entity.PartitionKey = entity.Email;
base.BeforeSave(entity);
}
// uses typeof(TEntity).Name by default, override with custom table name
protected override string GetTableName() => "UserMembership";
}
Query Operations
Find an entity by row and partition key. Note, table storage requires both.
var repository = serviceProvider.GetRequiredService<ITableRepository<Item>>();
var readResult = await repository.FindAsync(rowKey, partitionKey);
Find all by filter expression
var queryResults = await repository.FindAllAsync(r => r.IsActive);
Find all by filter expression
var itemResult = await repository.FindOneAsync(r => r.Name == itemName);
Find a page of items by filter. Note, Azure Table storage only supports forward paging by Continuation Token.
var pageResult = await repository.FindPageAsync(
filter: r => r.IsActive,
pageSize: 20);
// loop through pages
while (!string.IsNullOrEmpty(pageResult.ContinuationToken))
{
// get next paging using previous continuation token
pageResult = await repository.FindPageAsync(
filter: r => r.IsActive,
continuationToken: pageResult.ContinuationToken,
pageSize: 20);
}
Update Operations
Create an item
var createdItem = await repository.CreateAsync(item);
Update an item
var updatedItem = await repository.UpdateAsync(item);
Save or Upsert an item
var savedItem = await repository.SaveAsync(item);
RowKey and PartitionKey
Azure Table Storage requires both a RowKey
and PartitionKey
The base repository will set the RowKey
if it hasn't already been set using the NewRowKey()
method. The default implementation is Ulid.NewUlid().ToString()
If PartitionKey
hasn't been set, RowKey
will be used.
Batch Operations
Bulk insert data
await repository.BatchAsync(items);
Batch Merge data
await repository.BatchAsync(items, TableTransactionActionType.UpdateMerge);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Azure.Data.Tables (>= 12.9.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.1)
- ulid (>= 1.3.4)
-
net6.0
- Azure.Data.Tables (>= 12.9.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.1)
- ulid (>= 1.3.4)
-
net7.0
- Azure.Data.Tables (>= 12.9.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.1)
- ulid (>= 1.3.4)
-
net8.0
- Azure.Data.Tables (>= 12.9.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.1)
- ulid (>= 1.3.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.