Exemplo n.º 1
0
        public void FixtureSetup()
        {
            var provider = new NHibernateProvider();

            _config = provider.CreateConfiguration();

            _sessionFactory = provider.CreateSessionFactory(_config);

            _session = _sessionFactory.OpenSession();

            provider.ExportSchema(_config, _session.Connection);

            using (var trans = _session.BeginTransaction())
            {
                var modelCreator = new NHibernateQueryingModel();
                modelCreator.CreateModel(_session);
                trans.Commit();
            }

            _query = new QueryAdapter(_session);

            QueryableExtensions.EagerFetchingProvider = new EagerFetchingProvider();
            QueryableExtensions.LazyQueryingProvider  = new LazyResultProvider();
            QueryableExtensions.AsyncQueryingProvider = new AsyncQueryProvider();
        }
Exemplo n.º 2
0
 public Database Get()
 {
     if (database == null)
     {
         EnsureSessionFactory();
         database = new Database(sessionFactory.OpenSession());
     }
     return(database);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Gets a persistence test builder using a specified session instance.  A single session will be created
        /// during the lifetime of the test and it will be diposed at the end.
        /// </summary>
        /// <returns>The persistence test builder.</returns>
        /// <param name="sessionFactory">A session factory.</param>
        public static PersistenceTestBuilder UsingSessionFactory(global::NHibernate.ISessionFactory sessionFactory)
        {
            var sessionProvider = new SessionProvider(() => new SessionAdapter(sessionFactory.OpenSession()), true);

            return(new PersistenceTestBuilder(sessionProvider));
        }