在 nhibernate 中自动映射实体
您好,我在映射命名空间“nhibernateTest.Domain”中包含的所有实体时遇到了一个小问题。它基本上包含所有 Map 类,如 StudentMap、DepartmentMap 等。现在,在正常的 nhibernate 情况下,我们过去所做的是:
private ISessionFactory _sessionFactory;
private Configuration _configuration;
[TestFixtureSetUp]
public void TestFixtureSetUp()
{
_configuration = new Configuration().Configure().AddAssembly("nHibernateTest");
_sessionFactory = _configuration.BuildSessionFactory();
}
现在它过去所做的是。查找我的命名空间中的所有“*.hbm.xml”文件并自动映射它们...
有人可以告诉我如何对流畅的 nHibernate 执行相同的操作吗?这样它就会查找所有地图类并自动映射它们,这样我就不必为不同的地图类单独创建会话?
hii i am having a little problem in mapping all the entities in contained in the namespace "nhibernateTest.Domain" . it basically contains all the Map Classes like , StudentMap, DepartmentMap etc. .. now in case of normal nhibernate what we used to do is :
private ISessionFactory _sessionFactory;
private Configuration _configuration;
[TestFixtureSetUp]
public void TestFixtureSetUp()
{
_configuration = new Configuration().Configure().AddAssembly("nHibernateTest");
_sessionFactory = _configuration.BuildSessionFactory();
}
now what it used to do is . look for all the "*.hbm.xml" files in my namespace and automatically map them...
can someone tell me how to do the same for fluent nHibernate ? so that it looks for all map classes and automatically map them so that i dont have to create the session separately for diffrent Map classes ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在应用程序中配置 Fluent NHibernate 时,您需要指定映射。这通常是通过
上面的代码来自这个优秀的链接 来完成的讨论如何配置 Fluent。
You would need to specify your mappings when configuring Fluent NHibernate in your application. This is typically done by
The code above is from this excellent link which talks about how to configure Fluent.