Example #1
0
        private static IServiceCollection ConfigurePerRequestBillChopContext(this IServiceCollection services)
        {
            return(services.AddScoped((serviceProvider) =>
            {
                var transaction = serviceProvider.GetService <DbTransaction>() ?? throw new Exception("Could not acquire DbTransaction service");
                var options = serviceProvider.GetService <DbContextOptions <BillChopContext> >() ?? throw new Exception("Could not acquire DbContextOptions service");

                var context = new BillChopContext(options);
                context.Database.UseTransaction(transaction);
                return context;
            }));
        }
Example #2
0
        public static IHost MigrateBillChopDb(this IHost webHost)
        {
            var connectionString = ConnectionStringResolver.GetBillChopDbConnectionString();
            var options          = new DbContextOptionsBuilder <BillChopContext>()
                                   .UseSqlServer(connectionString)
                                   .UseLazyLoadingProxies()
                                   .Options;

            var dbContext = new BillChopContext(options);

            dbContext.Database.Migrate();

            return(webHost);
        }
 public LoanEFRepository(BillChopContext context)
 {
     this.context = context;
 }
 public GroupEFRepository(BillChopContext context)
 {
     this.context = context;
 }
Example #5
0
 public PaymentEFRepository(BillChopContext context)
 {
     this.context = context;
 }
Example #6
0
 public UserEFRepository(BillChopContext context)
 {
     this.context = context;
 }