【发布时间】:2017-02-07 21:25:28
【问题描述】:
我有一个项目,我的映射和实体存储在其他类库中,而 NHibernate 层存储在另一个项目中。在我的测试项目中,我想通过 fluently configure... Mappings... 通过 assebly 而不是单独添加这些映射。在下面的代码中,您可以看到我只添加了一个实体。但我想将其配置为扫描我的其他程序集。我确定我只是在这里遗漏了明显的东西。任何指针将不胜感激...
[Test]
public void Can_generate_schemaFluently()
{
var cfg = new Configuration();
cfg.Configure();
Configuration configuration = null;
ISessionFactory SessionFactory = null;
ISession session = null;
SessionFactory = Fluently.Configure(cfg)
*** WOULD LIKE TO ADD MY ASSEBLIES and autoscan for objects instead ***
.Mappings(m => m.FluentMappings
.Add(typeof(StudentEOMap))
)
.ExposeConfiguration(x => configuration = x)
.BuildSessionFactory();
session = SessionFactory.OpenSession();
object id;
using (var tx = session.BeginTransaction())
{
var result = session.Get<StudentEO>(1541057);
tx.Commit();
Assert.AreEqual(result.StudId, 1541057);
}
session.Close();
}
【问题讨论】:
标签: nhibernate fluent-nhibernate fluent-nhibernate-mapping