Esempio n. 1
0
        public BaseDao(IConnectionFactory connectionFactory)
        {
            var entityManager = EntityManagerFactory.CreateEntityManager(connectionFactory);

            _fluentEntity      = entityManager.FluentEntity();
            _fluentTransaction = entityManager.FluentTransaction();
            _fluentDelete      = _fluentEntity.Delete <T>();
        }
Esempio n. 2
0
        public DataSeeder()
        {
            var appSettings       = ConfigurationHelper.GetValues(ApolloTestDatabaseKey);
            var connectionFactory = new ConnectionFactory(appSettings[0]);

            EntityManager = EntityManagerFactory.CreateEntityManager(connectionFactory);
            FluentEntity  = EntityManager.FluentEntity();
            InitSeedData();
        }
Esempio n. 3
0
        public void OneTimeSetup()
        {
            ConfigurationHelper.ConfigurationRoot = new ConfigurationBuilder()
                                                    .AddJsonFile("testsettings.json")
                                                    .Build();
            var appSettings       = ConfigurationHelper.GetValues("Apollo_Test");
            var connectionFactory = new ConnectionFactory(appSettings[0]);

            _daoHelper    = new DaoHelper(connectionFactory);
            _fluentEntity = EntityManagerFactory.CreateEntityManager(connectionFactory).FluentEntity();
        }
Esempio n. 4
0
        public RepositoryHelper()
        {
            ConfigurationHelper.ConfigurationRoot = new ConfigurationBuilder()
                                                    .AddJsonFile("testsettings.json")
                                                    .Build();
            var appSettings       = ConfigurationHelper.GetValues("Apollo_Test");
            var connectionFactory = new ConnectionFactory(appSettings[0]);

            FluentEntity      = EntityManagerFactory.CreateEntityManager(connectionFactory).FluentEntity();
            RepositoryFactory = new RepositoryFactory(connectionFactory);
            FillTypes         = new HashSet <EntityType>();
        }
Esempio n. 5
0
        public UnitOfWork(IConnectionFactory connectionFactory)
        {
            var repositoryFactory = new RepositoryFactory(connectionFactory);

            _entityManager = EntityManagerFactory.CreateEntityManager(connectionFactory);

            RepositoryInfrastructure = repositoryFactory.CreateRepositoryInfrastructure();
            RepositoryMovie          = repositoryFactory.CreateRepositoryMovie();
            RepositorySchedule       = repositoryFactory.CreateRepositorySchedule();
            RepositoryTicket         = repositoryFactory.CreateRepositoryTicket();
            RepositoryUser           = repositoryFactory.CreateRepositoryUser();
        }
Esempio n. 6
0
 public static EntityManager getEm()
 {
     if (em == null)
     {
         emf = Persistence.CreateEntityManagerFactory("webAppPersistenceUnit");
         em  = emf.CreateEntityManager();
     }
     if (!em.IsOpen())
     {
         em = emf.CreateEntityManager();
     }
     return(em);
 }
        public async Task Test_Transaction_Nested_DifferentConnections()
        {
            ConfigurationHelper.ConfigurationRoot = new ConfigurationBuilder()
                                                    .AddJsonFile("testsettings.json")
                                                    .Build();
            var appSettings       = ConfigurationHelper.GetValues("Apollo_Test");
            var connectionFactory = new ConnectionFactory(appSettings[0]);
            var _entityManager2   = EntityManagerFactory.CreateEntityManager(connectionFactory);

            var genre1Name = "Drama";
            var genre2Name = "Horror";

            try
            {
                await _entityManager.FluentTransaction()
                .PerformBlock(async() =>
                {
                    await _entityManager2.FluentTransaction()
                    .PerformBlock(async() =>
                    {
                        await _entityManager.FluentEntity().InsertInto(new GenreMock
                        {
                            RowVersion = DateTime.Now,
                            Name       = genre1Name
                        }).ExecuteAsync();
                    }).Commit();


                    await _entityManager.FluentEntity().InsertInto(new GenreMock
                    {
                        RowVersion = DateTime.Now,
                        Name       = genre2Name
                    }).ExecuteAsync();
                    throw new InvalidOperationException();
                })
                .Commit();
            }
            catch (InvalidOperationException)
            {
                // ignore
            }

            var genres = (await _entityManager.FluentEntity().SelectAll <GenreMock>().QueryAsync())
                         .Select(g => g.Name)
                         .ToList();

            genres.Should().NotContain(genre1Name);
            genres.Should().NotContain(genre2Name);
        }
Esempio n. 8
0
        public void OneTimeSetup()
        {
            ConfigurationHelper.ConfigurationRoot = new ConfigurationBuilder()
                                                    .AddJsonFile("testsettings.json")
                                                    .Build();
            var appSettings       = ConfigurationHelper.GetValues("Apollo_Test");
            var connectionFactory = new ConnectionFactory(appSettings[0]);

            _entityManager = EntityManagerFactory.CreateEntityManager(connectionFactory);
            _fluentEntity  = _entityManager.FluentEntity();
            _selectHelper  = new FluentEntitySelectTestHelper(_entityManager);
            _deleteHelper  = new FluentEntityDeleteTestHelper(_entityManager);
            _updateHelper  = new FluentEntityUpdateTestHelper(_entityManager);
            _insertHelper  = new FluentEntityInsertTestHelper(_entityManager);
        }
Esempio n. 9
0
 public DBHelper()
 {
     entityManager = EntityManagerFactory.CreateEntityManager();
 }