Rystem.RepositoryFramework allows you to use correctly concepts like repository pattern, CQRS and DDD. You have interfaces for your domains, auto-generated api, auto-generated HttpClient to simplify connection "api to front-end", a functionality for auto-population in memory of your models, a functionality to simulate exceptions and waiting time from external sources to improve your implementation/business test and load test.
$ dotnet add package Rystem.RepositoryFramework.Infrastructure.MsSqlExample from unit test with a business integration too.
services
.AddRepository<Cat, Guid>(settings =>
{
settings
.WithMsSql(x =>
{
x.Schema = "repo";
x.ConnectionString = configuration["ConnectionString:Database"];
})
.WithPrimaryKey(x => x.Id, x =>
{
x.ColumnName = "Key";
})
.WithColumn(x => x.Paws, x =>
{
x.ColumnName = "Zampe";
x.IsNullable = true;
});
});
You found the IRepository<Cat, Guid> in DI to play with it.
You have to run a method after the service collection build during startup. This method creates your tables.
var app = builder.Build();
await app.Services.WarmUpAsync();
With automated api, you may have the api implemented with your dataverse integration. You need only to add the AddApiFromRepositoryFramework and UseApiForRepositoryFramework
builder.Services.AddApiFromRepositoryFramework()
.WithDescriptiveName("Repository Api")
.WithPath(Path)
.WithSwagger()
.WithVersion(Version)
.WithDocumentation()
.WithDefaultCors("http://example.com");
var app = builder.Build();
app.UseApiForRepositoryFramework()
.WithNoAuthorization();