Last active
February 7, 2024 06:36
-
-
Save gistlyn/3abcb76db6be3bd56a3505cd6effb8a7 to your computer and use it in GitHub Desktop.
Configure dynamic RDBMS validations source
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using ServiceStack; | |
using ServiceStack.Data; | |
using ServiceStack.Caching; | |
[assembly: HostingStartup(typeof(MyApp.ConfigureValidation))] | |
namespace MyApp; | |
public class ConfigureValidation : IHostingStartup | |
{ | |
// Add support for dynamically generated db rules | |
public void Configure(IWebHostBuilder builder) => builder | |
.ConfigureServices(services => { | |
services.AddSingleton<IValidationSource>(c => | |
new OrmLiteValidationSource( | |
c.GetRequiredService<IDbConnectionFactory>(), | |
c.GetRequiredService<MemoryCacheClient>())); | |
}) | |
.ConfigureAppHost(appHost => | |
appHost.Resolve<IValidationSource>().InitSchema()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment