本文整理汇总了C#中Spring.Data.NHibernate.HibernateTemplate.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# HibernateTemplate.Execute方法的具体用法?C# HibernateTemplate.Execute怎么用?C# HibernateTemplate.Execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Spring.Data.NHibernate.HibernateTemplate
的用法示例。
在下文中一共展示了HibernateTemplate.Execute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoInTransaction
public object DoInTransaction(ITransactionStatus status)
{
Assert.IsTrue(!TransactionSynchronizationManager.HasResource(sf), "Hasn't thread session");
Assert.IsTrue(!status.IsNewTransaction, "Is not new transaction");
Assert.IsFalse(TransactionSynchronizationManager.CurrentTransactionReadOnly);
Assert.IsFalse(TransactionSynchronizationManager.ActualTransactionActive);
HibernateTemplate ht = new HibernateTemplate(sf);
ht.TemplateFlushMode = TemplateFlushMode.Eager;
object returnValue = ht.Execute(new HibernateDelegate(Del));
Assert.IsTrue(TransactionSynchronizationManager.HasResource(sf), "Has thread session");
return null;
}
示例2: TransactionMethod
private object TransactionMethod(ITransactionStatus status)
{
Assert.IsTrue(TransactionSynchronizationManager.HasResource(sf), "Has thread session");
HibernateTemplate ht = new HibernateTemplate(sf);
object returnValue = ht.Execute(new HibernateDelegate(Del));
status.SetRollbackOnly();
return null;
}
示例3: UpdateDatabaseSchema
/// <summary>
/// Execute schema update script, determined by the Configuration object
/// used for creating the SessionFactory. A replacement for NHibernate's
/// SchemaUpdate class, for automatically executing schema update scripts
/// on application startup. Can also be invoked manually.
/// </summary>
/// <remarks>
/// Fetch the LocalSessionFactoryObject itself rather than the exposed
/// SessionFactory to be able to invoke this method, e.g. via
/// <code>LocalSessionFactoryObject lsfo = (LocalSessionFactoryObject) ctx.GetObject("mySessionFactory");</code>.
/// <p>
/// Uses the SessionFactory that this bean generates for accessing a ADO.NET
/// connection to perform the script.
/// </p>
/// </remarks>
public virtual void UpdateDatabaseSchema()
{
log.Info("Updating database schema for Hibernate SessionFactory");
HibernateTemplate hibernateTemplate = new HibernateTemplate(sessionFactory);
hibernateTemplate.TemplateFlushMode = TemplateFlushMode.Never;
hibernateTemplate.Execute(
new HibernateDelegate(delegate(ISession session)
{
IDbConnection con = session.Connection;
Dialect dialect = Dialect.GetDialect(Configuration.Properties);
DatabaseMetadata metadata = new DatabaseMetadata((DbConnection) con, dialect);
string[] sql = Configuration.GenerateSchemaUpdateScript(dialect, metadata);
ExecuteSchemaScript(con, sql);
return null;
}));
}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:31,代码来源:LocalSessionFactoryObject.cs
示例4: CreateDatabaseSchema
/// <summary>
/// Execute schema creation script, determined by the Configuration object
/// used for creating the SessionFactory. A replacement for NHibernate's
/// SchemaExport class, to be invoked on application setup.
/// </summary>
/// <remarks>
/// Fetch the LocalSessionFactoryObject itself rather than the exposed
/// SessionFactory to be able to invoke this method, e.g. via
/// <code>LocalSessionFactoryObject lsfo = (LocalSessionFactoryObject) ctx.GetObject("mySessionFactory");</code>.
/// <p>
/// Uses the SessionFactory that this bean generates for accessing a ADO.NET
/// connection to perform the script.
/// </p>
/// </remarks>
public void CreateDatabaseSchema()
{
log.Info("Creating database schema for Hibernate SessionFactory");
HibernateTemplate hibernateTemplate = new HibernateTemplate(sessionFactory);
hibernateTemplate.Execute(
new HibernateDelegate(delegate (ISession session)
{
IDbConnection con = session.Connection;
Dialect dialect = Dialect.GetDialect(Configuration.Properties);
string[] sql = Configuration.GenerateSchemaCreationScript(dialect);
ExecuteSchemaScript(con, sql);
return null;
}));
}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:29,代码来源:LocalSessionFactoryObject.cs