1
我試圖把我流利的映射過去基本的東西,我已經在這裏找到:Fluently.Configure沒有明確進入類型
http://wiki.fluentnhibernate.org/Fluent_configuration
在那裏他們明確地添加各類型如下:
ISessionFactory localFactory =
Fluently.Configure()
.Database(ObjectFactory.GetInstance<SybaseConfiguration>().GetSybaseDialect("BLAH"))
.Mappings(m =>
{
m.HbmMappings
.AddFromAssemblyOf<StudTestEO>();
m.FluentMappings
.AddFromAssemblyOf<StudTestEO>()
.AddFromAssemblyOf<StudTestEOMap>();
})
.BuildSessionFactory(); .BuildSessionFactory();
,並試圖能夠採取大會,得到它的類型的列表,並通過在 代替
個kindf這樣
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();
爲了得到它加載genericly,而不是明確的類型..
已經沒有人這樣做,或看到任何好文章鏈接我應該看?
謝謝,
E-