コード例 #1
0
        public void TestA()
        {
            using (var scope = _contextScopeFactory.CreateContextScope())
            {
                var testDbContext = scope.GetContext <TestDbContext>();

                var entityA = new EntityA {
                    ValueA = $"some value A {DateTime.Now:s}"
                };

                testDbContext.Set <EntityA>().Add(entityA);

                testDbContext.SaveChanges();

                _entityBService.TestB();

                scope.Save();
            }
        }
コード例 #2
0
        public void TestB()
        {
            using (var scope = _contextScopeFactory.CreateContextScope())
            {
                var testDbContext = scope.GetContext <TestDbContext>();

                // var entitiesA = testDbContext.Set<EntityA>().ToList();

                var entityB = new EntityB {
                    ValueB = $"some value B {DateTime.Now:s}"
                };

                testDbContext.Set <EntityB>().Add(entityB);

                testDbContext.SaveChanges();

                scope.Save();
            }
        }