public EmployerFinanceDbContext CreateDbContext()
        {
            var optionsBuilder = new DbContextOptionsBuilder <EmployerFinanceDbContext>()
                                 .UseSqlServer(_dbConnection)
                                 .ConfigureWarnings(w => w.Throw(RelationalEventId.QueryClientEvaluationWarning));

            if (_hostingEnvironment.IsDevelopment())
            {
                optionsBuilder.UseLoggerFactory(_loggerFactory);
            }

            var dbContext = new EmployerFinanceDbContext(optionsBuilder.Options);

            return(dbContext);
        }
        public EmployerFinanceDbContext CreateDbContext()
        {
            var synchronizedStorageSession = _unitOfWorkContext.Find <SynchronizedStorageSession>();
            var sqlStorageSession          = synchronizedStorageSession.GetSqlStorageSession();

            var optionsBuilder = new DbContextOptionsBuilder <EmployerFinanceDbContext>()
                                 .UseSqlServer(sqlStorageSession.Connection)
                                 .ConfigureWarnings(w => w.Throw(RelationalEventId.QueryClientEvaluationWarning));

            if (_hostingEnvironment.IsDevelopment())
            {
                optionsBuilder.UseLoggerFactory(_loggerFactory);
            }

            var dbContext = new EmployerFinanceDbContext(optionsBuilder.Options);

            dbContext.Database.UseTransaction(sqlStorageSession.Transaction);

            return(dbContext);
        }
        public static async Task <IEnumerable <AccountTransfer> > GetTransfersByTargetAccountId(this EmployerFinanceDbContext db, long accountId, long targetAccountId, string periodEnd)
        {
            var transfers = await db.SqlQueryAsync <AccountTransfer>(
                "[employer_financial].[GetTransferTransactionDetails] @accountId = {0}, @targetAccountId = {1}, @periodEnd = {2}",
                accountId,
                targetAccountId,
                periodEnd).ConfigureAwait(false);

            return(transfers);
        }