本文整理汇总了C#中NHibernate.Tool.hbm2ddl.SchemaExport.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# SchemaExport.Execute方法的具体用法?C# SchemaExport.Execute怎么用?C# SchemaExport.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Tool.hbm2ddl.SchemaExport
的用法示例。
在下文中一共展示了SchemaExport.Execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public string Create()
{
var schemaExport = new SchemaExport(configuration);
databaseProvider.CreateIfNotExists();
var stringBuilder = new StringBuilder();
schemaExport.Create(x => stringBuilder.Append(x), false);
var statement = stringBuilder.ToString();
statement = string.IsNullOrWhiteSpace(statement) ? null : statement;
if (!databaseProvider.Exists())
{
databaseProvider.Create();
schemaExport.Execute(false, true, false);
}
else
{
try
{
new SchemaValidator(configuration).Validate();
}
catch
{
schemaExport.Execute(false, true, false);
}
}
return statement;
}
示例2: CreateSchema
public void CreateSchema(bool recreate)
{
if (_sessionFactory == null)
_sessionFactory = CreateSessionFactory();
var schemaExport = new SchemaExport(_configuration);
if (recreate)
schemaExport.Execute(false, true, true);
schemaExport.Execute(false, true, false);
}
示例3: CanCreate_FromScratch
public void CanCreate_FromScratch()
{
SchemaExport schemaCreator = new SchemaExport(CreateConfiguration(xml1));
schemaCreator.Execute((s) =>
{
Debug.WriteLine(" === Create === ");
Debug.WriteLine(s);
}, true, false);
schemaCreator.Execute((s) =>
{
Debug.WriteLine(" === Drop === ");
Debug.WriteLine(s);
}, true, true);
}
示例4: CreateDatabase
public static void CreateDatabase()
{
CopyBlankDatabase();
var export = new SchemaExport(NHibernateHelper.Configuration);
export.Execute(true, true, false);
}
示例5: Application_Start
protected void Application_Start()
{
HibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize();
var configuration = GlobalConfiguration.Configuration;
var builder = new ContainerBuilder();
builder.ConfigureWebApi(configuration);
builder.RegisterControllers(typeof(MvcApplication).Assembly);
builder.Register(c => CreateSessionFactory()).As<ISessionFactory>().SingleInstance();
builder.Register(c =>
{
var sf = c.Resolve<ISessionFactory>();
var session = sf.OpenSession();
var export = new SchemaExport(SavedConfig);
export.Execute(true, true, false, session.Connection, null);
return session;
}
).As<ISession>().SingleInstance();
builder.RegisterType<UnitOfWork>().InstancePerHttpRequest();
var container = builder.Build();
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
var resolver = new AutofacWebApiDependencyResolver(container);
configuration.ServiceResolver.SetResolver(resolver);
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
BundleTable.Bundles.RegisterTemplateBundles();
}
示例6: Execute
public void Execute(Action<ISession> action)
{
var cfg = new SQLiteConfiguration()
.InMemory()
.ShowSql()
.ConfigureProperties(new Configuration());
// UGLY HACK
var nhVersion = typeof(Configuration).Assembly.GetName().Version;
if (!nhVersion.ToString().StartsWith("2.0."))
{
cfg.SetProperty("proxyfactory.factory_class",
"NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle");
}
PersistenceModel.Configure(cfg);
var sessionFactory = cfg.BuildSessionFactory();
using (var session = sessionFactory.OpenSession())
{
using (var tx = session.BeginTransaction())
{
SchemaExport export = new SchemaExport(cfg);
export.Execute(true, true, false, false, session.Connection, null);
tx.Commit();
}
using (var tx = session.BeginTransaction())
{
action(session);
tx.Commit();
}
}
}
示例7: buildSchema
private void buildSchema()
{
var cfg = NHibernateSessionProvider.Configuration;
var schemaExport = new SchemaExport(cfg);
//schemaExport.Create(false, true);
schemaExport.Execute(false, true, false, Session.Connection, null);
}
示例8: Main
static void Main(string[] args)
{
//var assemblyNames = ConfigurationManager.AppSettings["nhibernate.assemblies"];
//if (assemblyNames.IsNullOrEmpty())
// throw new ConfigurationErrorsException("value required for nhibernate.assemblies, comma seperated list of assemblies");
//var config = new NHibernate.Cfg.Configuration();
//config.Configure();
//foreach (MappingAssembly assembly in TitanConfiguration.Instance.MappingAssemblies)
// config.AddAssembly(assembly.Name);
TitanFramework.Data.NHib.NHibernateHelper.InitialIze();
var config = TitanFramework.Data.NHib.NHibernateHelper.Configuration;
var rebuildDatabase = ConfigurationManager.AppSettings["nhibernate.rebuilddatabase"];
if (TitanFramework.Extensions.StringExtensions.IsNullOrEmpty(rebuildDatabase))
throw new ConfigurationErrorsException("value required for nhibernate.assemblies, comma seperated list of assemblies");
switch (rebuildDatabase.ToLower())
{
case "rebuild":
var schemaExport = new SchemaExport(config);
schemaExport.Drop(false, true);
schemaExport.Execute(true, false, false);
break;
case "update":
var schemaUpdate = new SchemaUpdate(config);
schemaUpdate.Execute(true, true);
break;
}
}
示例9: Main
private static void Main(string[] args)
{
XmlConfigurator.Configure();
var log = LogManager.GetLogger(typeof (Program));
SetupNHibernateValidator();
var nhibernateConfig = new Configuration().Configure();
nhibernateConfig.Initialize();
ISessionFactory sessionFactory = nhibernateConfig.BuildSessionFactory();
var schemaExport = new SchemaExport(nhibernateConfig);
schemaExport.Execute(false, true, false);
var junk = new Product
{
Name = "Spiffy Junk",
Description = string.Empty,
UnitPrice = -1M
};
var ve = Environment.SharedEngineProvider.GetEngine();
var invalidValues = ve.Validate(junk);
foreach (var invalidValue in invalidValues)
log.InfoFormat("{0} {1}",
invalidValue.PropertyName,
invalidValue.Message);
}
示例10: BuildSchema
public static IDbConnection BuildSchema(ISession Session, Configuration configuration)
{
var export = new SchemaExport(configuration);
var connection = Session.Connection;
export.Execute(true, true, false, connection, null);
return connection;
}
示例11: SqlLiteBuilder
public SqlLiteBuilder()
{
var showSql = GetShowSql();
var configuration = new Configuration()
.Proxy(p => p.ProxyFactoryFactory<DefaultProxyFactoryFactory>())
.DataBaseIntegration(db =>
{
db.Dialect<SQLiteDialect>();
db.Driver<SQLite20Driver>();
db.ConnectionString = "data source=:memory:";
})
.SetProperty(Environment.ReleaseConnections, "on_close")
.SetProperty(Environment.ShowSql, showSql)
.AddAssembly(Assembly.GetCallingAssembly());
_sessionFactory = Fluently.Configure(configuration)
.Mappings(mappings => mappings.FluentMappings.AddFromAssemblyOf<SqlLiteBuilder>())
.BuildSessionFactory();
_session = _sessionFactory.OpenSession();
var textWriter = GetTextWriter();
var schemaExport = new SchemaExport(configuration);
schemaExport.Execute(false, true, false, _session.Connection, textWriter);
}
示例12: NewsManagementInMemoryDatabaseFactory
public NewsManagementInMemoryDatabaseFactory(ProvideInMemoryNewsManagementSessionFactoryInitialisation provideSessionFactoryInitialisation)
: base(provideSessionFactoryInitialisation)
{
provideSessionFactoryInitialisation.InitialiseSessionFactory();
SchemaExport export = new SchemaExport(provideSessionFactoryInitialisation.Configuration);
export.Execute(true, true, false, Session.Connection, null);
}
示例13: CreateDB
public void CreateDB()
{
SchemaExport schemaExport = new SchemaExport(Common.GetNHibernateConnnectInfo());
schemaExport.Execute(false, true, false);
CreateBlog();
}
示例14: Create_a_database_schema_creation_script
public void Create_a_database_schema_creation_script()
{
var export = new SchemaExport(_cfg);
var sb = new StringBuilder();
TextWriter output = new StringWriter(sb);
export.Execute(true, false, false, false, null, output);
}
示例15: can_create_schema
public void can_create_schema()
{
Configuration cfg = new NHibernate.Cfg.Configuration();
SchemaExport exporter = new SchemaExport(cfg.Configure());
exporter.Create(true, true);
exporter.Execute(false, true, false, true);
}