Beispiel #1
0
        public void BuildSchema()
        {
            using (var session = _source.Configuration().BuildSessionFactory().OpenSession())
            {
                var connection    = session.Connection;
                var configuration = _source.Configuration();

                var dialect = Dialect.GetDialect(_databaseSettings.GetProperties());
                var drops   = configuration.GenerateDropSchemaScript(dialect);

                executeScripts(drops, connection);

                var scripts = configuration.GenerateSchemaCreationScript(dialect);
                executeScripts(scripts, connection);
            }
        }
Beispiel #2
0
        public DomainEntity FindByPath(string path)
        {
            var  parts    = path.Split('/');
            var  typeName = parts[0];
            Guid id;

            if (!Guid.TryParse(parts[1], out id))
            {
                throw new ArgumentException("The value '{0}' does not contain a valid GUID identifier.", "path");
            }

            var theType = _source.Configuration().PersistedTypeByName(typeName);

            if (theType == null)
            {
                throw new ArgumentException("The value '{0}' refers to an unknown entity type.".ToFormat(path), "path");
            }
            return(_session.Get(theType, id) as DomainEntity);
        }
Beispiel #3
0
        public Configuration Configuration()
        {
            var formatter = new BinaryFormatter();

            if (File.Exists(SchemaWriter.NHIBERNATE_CONFIGURATION_FILE))
            {
                using (var stream = new FileStream(SchemaWriter.NHIBERNATE_CONFIGURATION_FILE, FileMode.Open, FileAccess.Read))
                {
                    return((Configuration)formatter.Deserialize(stream));
                }
            }

            var configuration = _inner.Configuration();

            using (var stream = new FileStream(SchemaWriter.NHIBERNATE_CONFIGURATION_FILE, FileMode.Create, FileAccess.Write))
            {
                formatter.Serialize(stream, configuration);
            }

            return(configuration);
        }
Beispiel #4
0
 public void build_the_configuration()
 {
     source.Configuration().ShouldNotBeNull();
 }
Beispiel #5
0
 public void get_address_type()
 {
     source.Configuration().PersistedTypeByName("address").ShouldEqual(typeof(Address));
     source.Configuration().PersistedTypeByName("Address").ShouldEqual(typeof(Address));
 }