using GerstITS.Data; using GerstITS.Data.EntityFramework; using GerstITS.Examples.Transactions.Migrations; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; namespace GerstITS.Examples.Transactions; internal class Program { #region Methods private static void Main(string[] args) { using var provider = BuildProvider(); using var scope = provider.CreateScope(); new TransactionRunner(scope.ServiceProvider.GetRequiredService(), scope.ServiceProvider.GetRequiredService()).Run(); } private static ServiceProvider BuildProvider() { var configuration = new ConfigurationBuilder().SetBasePath(AppDomain.CurrentDomain.BaseDirectory) .AddJsonFile("appsettings.json", true, true) .Build(); var container = new ServiceCollection(); container.AddSingleton(configuration); // A single configurator instance owns the kept-open SQLite in-memory connection for the whole run. container.AddSingleton(); container.AddSingleton(services => services.GetRequiredService()); container.AddTransient(_ => new DbContextOptionsBuilder().Options); container.AddScoped(); container.AddEntityFrameworkSession(); // Provide the repository, sessions, bulk operations and interceptors from the framework. new GerstITS.System.Module().RegisterComponents(container); new GerstITS.Data.Module().RegisterComponents(container); new GerstITS.Data.EntityFramework.Module().RegisterComponents(container); return container.BuildServiceProvider(); } #endregion }