A library based on EF Core, for development using Azure Tables is more productive. Click here to report bug or request feature.
PM> Install-Package FakeOrm.AzureTables -Version 1.0.5
public class Startup
{
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.UseAzureTablesRepository(Configuration);
//OR
services.UseAzureTablesRepository(Configuration.GetConnectionString("AzureTableConnection"));
}
}
In appsettings.json:
{
"ConnectionStrings": {
"AzureTableConnection": "DefaultEndpointsProtocol=https;AccountName=**************;AccountKey=*********;EndpointSuffix=core.windows.net"
}
}
using FakeOrm.AzureTables.Domain;
namespace YourWorkspace.YourAwesomeClass
{
//inherit from 'BaseEntity'
public class User : BaseEntity
{
//public constructor without parameters is required
public User() { }
}
}
using FakeOrm.AzureTables.Repository.Interface;
namespace YourWorkspace.YourAwesomeClass
{
[ApiController]
[Route("[controller]")]
public class UserController : ControllerBase
{
private readonly IAzureTableRepository<User> _repository;
public UserController(IAzureTableRepository<User> repository)
{
_repository = repository;
}
[HttpPost]
public async Task<IActionResult> Post()
{
var user = new User() { };
await _repository.CreateOrUpdateAsync(user);
return Ok();
}
}
}