views:

39

answers:

0
using System.Collections.Generic;
using DataLoader.Domain;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace UnitTest
{
    /// <summary>
    /// Unit test that reloads the database schema based on Hibernate mapping files.
    /// </summary>
    [TestClass]
    public class SchemaLoader
    {
        // Enable this test to reload the schema
        [TestMethod]
        public void ReloadSchema()
        {
            var cfg = new Configuration();
            IDictionary<string, string> props = new Dictionary<string, string>();
            props.Add("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
            props.Add("dialect", "NHibernate.Dialect.Oracle10gDialect");
            props.Add("connection.driver_class", "NHibernate.Driver.OracleClientDriver");
            props.Add("connection.connection_string", "Data Source=(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)))(CONNECT_DATA = (SERVICE_NAME = xe)));User Id=dbmonitor;Password=dbmonitor");
            cfg.AddProperties(props);
            cfg.AddAssembly(typeof(Pool).Assembly);

            var schemaExport = new SchemaExport(cfg);
            schemaExport.SetOutputFile("c:/db_monitor.sql");

            schemaExport.Create(true, true);
        }
    }
}

There's my code so far, now if I want to populate tables from an .sql file or .ddl file and then export it all to the db_monitor.sql file, how would I go about doing it.