Vb.net 项目与 C# 流利的 nHibernate 映射项目
成功尝试了 nHibernate 后,我现在想尝试使用 Fluent 进行映射。我的主要项目是在 vb.net 中,但我真的很想使用 C# 进行映射,因为 lambda 表达式功能使其更加清晰。您是否可以为映射文件创建一个单独的项目/程序集,而无需创建与域对象的循环依赖关系?
Having successfully tried out nHibernate, I would now like to try using Fluent for mapping. My main project is in vb.net but I would really like to use c# for the mappings since the lambda expression capability makes it much cleaner. Can you have a separate project/assembly for your mapping files without creating a circular dependency with domain objects?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您的域对象不(也不应该)依赖于 NHibernate 映射,无论它们是用传统方式(.hbm.xml 文件)还是使用 Fluent 定义的。您可以安全地将这些映射存储在另一个程序集中,并且只需由数据访问层 (DAL) 和可执行项目引用它们。由于您的域对象不需要对 DAL 的引用,因此它工作得很好。
只需按照 Fluent's Wiki 中的说明进行操作,并且在定义 CreateSessionFactory() 方法的同一程序集中,您可以需要您的测绘项目的参考。
-道格
Yes, your domain objects are not (and should not be) dependent on the NHibernate mappings, whether they be defined the traditional way (.hbm.xml files) or with Fluent. You can safely store these mappings in another assembly, and they only need to be referenced by your data access layer (DAL) and your executable project. Since your domain objects don't need a reference to your DAL, it works just fine.
Just follow the instructions at Fluent's Wiki and in the same assembly where you defined your CreateSessionFactory() method, you'll need a reference to your mapping project.
-Doug