Miha,

As an exercise, I downloaded your sample project (as mentioned in your
NHUsers post)
and modifed the "ConfigureNHibernate" to work the same way my project
does.

As far as I can tell, it _seems_ to be working, and I was able to
comment out _all_ of your CustomMappingConfiguration and conventions
code.

Modified routine (and helper "BuildSchema" method) is appended below.
Please let me know if this is works properly for you.

-Tom

----------------------------------------

        private ISessionFactory ConfigureNHibernate()
        {
            var mapping = AutoMap.AssemblyOf<Employee>()
                .Where(t => t.Name == "Employee" ||
                            t.Name == "HourlyRate" ||
                            t.Name == "NightlyRate")
                .Conventions.Add(
                // Do cascading saves on all entities so lists  will
be
                // automatically saved
                DefaultCascade.All(),

                // Turn on lazy loading, so will only read data that
is actually
                // displayed
                DefaultLazy.Always()
                );

            //var mapping = AutoMap.AssemblyOf<Employee>(new
CustomMappingConfiguration())
            //    .IncludeBase<Rate>()
            //    .Conventions.Setup(c =>
            //                           {
            //
c.Add<IdGenerationConvention>();
            //
c.Add<DefaultStringLengthConvention>();
            //
c.Add<IndexableConvention>();
            //
c.Add<CascadeAllConvention>();
            //                               //
c.Add<EagerLoadingConvention>();
            //
c.Add<DiscriminatorConvention>();
            //                           })
            //   .Override<Rate>(map =>
map.DiscriminateSubClassesOnColumn("RateType"))
            //   //.Override<HourlyRate>(map => map.Where("RateType =
'HourlyRate'"))
            //   //.Override<NightlyRate>(map => map.Where("RateType =
'NightlyRate'"))
            //    ;
            return Fluently.Configure()
                /* SQLite database */
                .Database(SQLiteConfiguration
                              .Standard
                              .UsingFile("db.sqlite3")
                              .ShowSql()
                )
                /*  SQL Server database */
                //.Database(
                //    MsSqlConfiguration.MsSql2008
                //    .ConnectionString(connectionString)
                //    .ShowSql())
                /* Use auto mapping */
                .Mappings(m => m.AutoMappings
                                   .Add(mapping)
                                   .ExportTo(".\\"))
                .ExposeConfiguration(BuildSchema)
                .BuildSessionFactory();


            //var nhConfig = config.BuildConfiguration();

            //new SchemaExport(nhConfig).Execute(true, true, false);

            //return nhConfig.BuildSessionFactory();
        }

        private static void BuildSchema(Configuration config)
        {
            try
            {
                // this NHibernate tool takes a configuration (with
mapping info)
                // and exports a database schema from it
                new SchemaExport(config)
                    .Create(true, true);
            }
            // This will be thrown if the mapping is bad, e.g. an
overide is missing
            catch (MappingException e)
            {
                throw new ApplicationException(
                    "\r\n    BuildSchema mapping exception:\r\n\r\n"
                    + e.Message + "\r\n\r\n", e);
            }
        }
    }

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibern...@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.

Reply via email to