当前位置: 首页>>代码示例>>C#>>正文


C# ISessionFactory.OpenStatelessSession方法代码示例

本文整理汇总了C#中ISessionFactory.OpenStatelessSession方法的典型用法代码示例。如果您正苦于以下问题:C# ISessionFactory.OpenStatelessSession方法的具体用法?C# ISessionFactory.OpenStatelessSession怎么用?C# ISessionFactory.OpenStatelessSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISessionFactory的用法示例。


在下文中一共展示了ISessionFactory.OpenStatelessSession方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateSession

        /// <summary>
        /// This method is invoked to allow
        /// the scope to create a properly configured session
        /// </summary>
        /// <param name="sessionFactory">From where to open the session</param>
        /// <param name="interceptor">the NHibernate interceptor</param>
        /// <returns>the newly created session</returns>
        protected override ISession CreateSession(ISessionFactory sessionFactory, IInterceptor interceptor)
        {
            ISession session = new StatelessSessionWrapper(sessionFactory.OpenStatelessSession());

            session.BeginTransaction();

            return session;
        }
开发者ID:shosca,项目名称:ActiveRecord,代码行数:15,代码来源:StatelessSessionScope.cs

示例2: ExecuteAuxilliaryDatabaseScripts

 public static void ExecuteAuxilliaryDatabaseScripts(this Configuration configuration, ISessionFactory sf)
 {
     dynamic exposed = new ExposedObjectSimple(configuration);
     foreach (var aux in exposed.auxiliaryDatabaseObjects)
     {
         var script = ((dynamic)new ExposedObjectSimple(aux)).sqlCreateString;
         using (var s = sf.OpenStatelessSession())
         {
             s.CreateSQLQuery((string)script).ExecuteUpdate();
         }
     }
 }
开发者ID:timiles,项目名称:NhCodeFirst,代码行数:12,代码来源:AuxDbExtensions.cs

示例3: ClearDatabase

        public static void ClearDatabase(Configuration cfg, ISessionFactory factory)
        {
            var tableNames = new List<string>();

            foreach (var clazz in cfg.ClassMappings)
            {
                tableNames.Add(clazz.Table.Name);
            }

            using (IStatelessSession session = factory.OpenStatelessSession())
            {
                using (IDbCommand cmd = session.Connection.CreateCommand())
                {
                    cmd.CommandType = CommandType.Text;

                    foreach (var tableName in tableNames)
                    {
                        cmd.CommandText = string.Format("DELETE FROM {0}", tableName);
                        cmd.ExecuteNonQuery();
                    }
                }
            }
        }
开发者ID:diabluchanskyi,项目名称:pablo,代码行数:23,代码来源:DatabaseCleaner.cs

示例4: StartUnitOfWork

        private static IUnitOfWork StartUnitOfWork(ISessionFactory sessionFactory, IEnumerable<UnitOfWorkOption> options)
        {
            if (options != null && options.Contains(UnitOfWorkOption.Stateless))
            {
                return new UnitOfWork(sessionFactory.OpenStatelessSession());
            }

            var session = sessionFactory.OpenSession();
            session.FlushMode = FlushMode.Commit;
            return new UnitOfWork(session) {ObjectContainer = Core.ObjectContainer.Get<IObjectContainer>()};
        }
开发者ID:AmandaMakino,项目名称:SisUrbe,代码行数:11,代码来源:UnitOfWorkFactory.cs

示例5: Setup

        public void Setup()
        {
            _sessionFactory = _configuration.BuildSessionFactory();
			_session = _sessionFactory.OpenStatelessSession();
            _transaction = _session.BeginTransaction();
        }
开发者ID:tarwn,项目名称:StaticVoid.OrmPerformance,代码行数:6,代码来源:BatchedStatelessConfiguration.cs

示例6: CreateTestData

		private void CreateTestData(ISessionFactory sessionFactory)
		{
			using (IStatelessSession session = sessionFactory.OpenStatelessSession())
			using (ITransaction tx = session.BeginTransaction())
			{
				NorthwindDbCreator.CreateNorthwindData(session);

				tx.Commit();
			}

			using (ISession session = sessionFactory.OpenSession())
			using (ITransaction tx = session.BeginTransaction())
			{
				NorthwindDbCreator.CreateMiscTestData(session);
				NorthwindDbCreator.CreatePatientData(session);
				tx.Commit();
			}
		}
开发者ID:Ruhollah,项目名称:nhibernate-core,代码行数:18,代码来源:LinqReadonlyTestsContext.cs

示例7: UnitOfWork

 public UnitOfWork(ISessionFactory sessionFactory)
 {
    _sessionFactory = sessionFactory;
    _readSession = _sessionFactory.OpenStatelessSession();
 }
开发者ID:ssajous,项目名称:DDDSample.Net,代码行数:5,代码来源:UnitOfWork.cs

示例8: OpenSession

		/// <summary>
		/// If the <see cref="AbstractScope.WantsToCreateTheSession"/> returned
		/// <c>true</c> then this method is invoked to allow
		/// the scope to create a properly configured session
		/// </summary>
		/// <param name="sessionFactory">From where to open the session</param>
		/// <param name="interceptor">the NHibernate interceptor</param>
		/// <returns>the newly created session</returns>
		public override ISession OpenSession(ISessionFactory sessionFactory, IInterceptor interceptor)
		{
			return new StatelessSessionWrapper(sessionFactory.OpenStatelessSession());
		}
开发者ID:sheefa,项目名称:Castle.ActiveRecord,代码行数:12,代码来源:StatelessSessionScope.cs

示例9: RunStatelessSession

 static void RunStatelessSession(ISessionFactory sessionFactory)
 {
     using (var session = sessionFactory.OpenStatelessSession())
     {
         session.Query<Value>().ToList();
     }
 }
开发者ID:rjperes,项目名称:NHPerformance,代码行数:7,代码来源:Program.cs

示例10: RunSql

 static void RunSql(ISessionFactory sessionFactory)
 {
     using (var session = sessionFactory.OpenStatelessSession())
     {
         //session.CreateSQLQuery("SELECT {v.*} FROM [Value] v").AddEntity("v", typeof(Value)).List<Value>();
         session.CreateSQLQuery("SELECT v.* FROM [Value] v").List();
     }
 }
开发者ID:rjperes,项目名称:NHPerformance,代码行数:8,代码来源:Program.cs


注:本文中的ISessionFactory.OpenStatelessSession方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。