devlooped / TableStorage

Repository pattern with POCO object support for storing to Azure / Cosmos DB Table Storage

Home Page:https://clarius.org/TableStorage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add an AttributedTableRepository<T> for easy consumption in DI scenarios

kzu opened this issue · comments

In DI scenarios, it's virtually impossible to inject a string with a target table name, or a Func<T, string> for the functions to retrieve a partition key or row key for an entity.

However, since we provide the corresponding attributes to make this simpler to consume when using the factory methods, we could also just provide a derived implementation that just uses those same defaults always, so registering it for DI is as simple as (for ASP.NET Core for example):

services.AddScoped(typeof(ITableRepository<>), typeof(AttributedTableRepository<>));