views:

10

answers:

0

I'm trying to take my fluent mapping past the basic stuff that I've found here:

http://wiki.fluentnhibernate.org/Fluent_configuration

Where they explicitly add each type like this:

ISessionFactory localFactory =
                Fluently.Configure()
                    .Database( ObjectFactory.GetInstance<SybaseConfiguration>().GetSybaseDialect( "BLAH" ) )
                    .Mappings( m =>
                    {
                        m.HbmMappings
                            .AddFromAssemblyOf<StudTestEO>();
                        m.FluentMappings
                            .AddFromAssemblyOf<StudTestEO>()
                            .AddFromAssemblyOf<StudTestEOMap>();
                    } )
                    .BuildSessionFactory();  .BuildSessionFactory();

and trying to be able to take the assembly, get a list of it's types and pass that in instead

kindf like this

string FullEoAssemblyFName = webAccessHdl.GetMapPath(EoAssemblyFName);
            string FullMapAssemblyFName = webAccessHdl.GetMapPath(MapAssemblyFName);
            string FullConfigFileName = webAccessHdl.GetMapPath("~/" + NHibernateConfigFileName);

            if (!File.Exists(FullEoAssemblyFName))
                throw new Exception("GetFactoryByConfigFile, EoAssemblyFName does not exist>" + FullEoAssemblyFName + "<");
            if (!File.Exists(FullMapAssemblyFName))
                throw new Exception("GetFactoryByConfigFile, MapAssemblyFName does not exist>" + FullMapAssemblyFName + "<");
            if (!File.Exists(FullConfigFileName))
                throw new Exception("GetFactoryByConfigFile, ConfigFile does not exist>" + FullConfigFileName + "<");

            Configuration configuration = new Configuration();

            Assembly EoAssembly = Assembly.LoadFrom(webAccessHdl.GetMapPath(EoAssemblyFName));
            Assembly MapAssembly = Assembly.LoadFrom(webAccessHdl.GetMapPath(MapAssemblyFName));

            Type[] EoType = EoAssembly.GetTypes();
            Type[] MapType = MapAssembly.GetTypes();
ISessionFactory localFactory =
                fluent.Mappings(
                    m =>
                        {

                            // how do i add all the types from type array here?
                            m.FluentMappings.Add(MapAssembly).AddFromAssembly(EoAssembly);


                        }
                )
                .BuildSessionFactory();

To get it to load the types genericly instead of explicitly..

has anyone done this, or see any good links to articles I should look at?

Thanks,

E-

related questions