本文整理汇总了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;
}
示例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();
}
}
}
示例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();
}
}
}
}
示例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>()};
}
示例5: Setup
public void Setup()
{
_sessionFactory = _configuration.BuildSessionFactory();
_session = _sessionFactory.OpenStatelessSession();
_transaction = _session.BeginTransaction();
}
示例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();
}
}
示例7: UnitOfWork
public UnitOfWork(ISessionFactory sessionFactory)
{
_sessionFactory = sessionFactory;
_readSession = _sessionFactory.OpenStatelessSession();
}
示例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());
}
示例9: RunStatelessSession
static void RunStatelessSession(ISessionFactory sessionFactory)
{
using (var session = sessionFactory.OpenStatelessSession())
{
session.Query<Value>().ToList();
}
}
示例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();
}
}