コード例 #1
0
        public static Task ImportProviders(this ProviderRelationshipsDbContext db, DataTable providersDataTable)
        {
            var providers = new SqlParameter("providers", SqlDbType.Structured)
            {
                TypeName = "Providers",
                Value    = providersDataTable
            };

            var now = new SqlParameter("now", DateTime.UtcNow);

            return(db.ExecuteSqlCommandAsync("EXEC ImportProviders @providers, @now", providers, now));
        }
コード例 #2
0
        public ProviderRelationshipsDbContext CreateDbContext()
        {
            var optionsBuilder = new DbContextOptionsBuilder <ProviderRelationshipsDbContext>()
                                 .UseSqlServer(_dbConnection)
                                 .ConfigureWarnings(w => w.Throw(RelationalEventId.QueryClientEvaluationWarning));

            if (_environmentService.IsCurrent(DasEnv.LOCAL))
            {
                optionsBuilder.UseLoggerFactory(_loggerFactory);
            }

            var dbContext = new ProviderRelationshipsDbContext(optionsBuilder.Options);

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

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

            if (_environmentService.IsCurrent(DasEnv.LOCAL))
            {
                optionsBuilder.UseLoggerFactory(_loggerFactory);
            }

            var dbContext = new ProviderRelationshipsDbContext(optionsBuilder.Options);

            dbContext.Database.UseTransaction(sqlStorageSession.Transaction);

            return(dbContext);
        }