Easily convert POCOs (Plain Old CLR Objects) to Azure Table Storage TableEntities and vice versa, fork of TableStorage.Abstractions.TableEntityConverters with System.Text.Json instead of Newtonsoft.Json
$ dotnet add package TableStorageEntitiesChanges from the base library:
TableRepository<T>(), more information below.TableRepositoryExtensions for injections with services.AddTableStorage().TableRepository<T>() has no tests yet, use it at your own risk.TableRepository<T> to containerSimplest usage:
services.AddTableStorage("<yourAzureStorageConnectionString>", typeof(Program).Assembly);
This will scan the assembly and find all usages of TableRepository<T>, register them to your container as scoped objects.
You can also pass JsonSerializerOptions, this will be set as EntityConvert.SetDefaultJsonSerializerOptions(options);, so all your conversions use the same options by default. This is particularly useful for converters.
var options = new JsonSerializerOptions
{
IgnoreNullValues = true,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
};
options.Converters.Add(new JsonStringEnumConverter());
services.AddTableStorage("<yourAzureStorageConnectionString>", typeof(Program).Assembly, options);
TableRepository<T> to your classOnce you register, you can inject TableRepository<T> as if you are injecting any other service:
public class MyService
{
private readonly TableRepository<MyEntity> _tableRepository;
public MyService(TableRepository<MyEntity> tableRepository)
{
_tableRepository = tableRepository;
}
}
TableRepository<T>TODO