NHibernate 映射属性与流畅的 NHibernate [英] NHibernate mapping attributes vs fluent NHibernate

查看:33
本文介绍了NHibernate 映射属性与流畅的 NHibernate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

映射属性是否提供与 nhib hbm 相同的多功能性?你能把它们和 FNH 一起使用来处理 FNH 还没有做的和 hbm 一样好的事情吗?

Do mapping attributes offer the same versatility as nhib hbm's do? Can you use them together with FNH to handle things FNH doesn't yet do as well as hbm's can?

干杯,
贝瑞尔

通过映射属性,我指的不是 hbm 文件;显然,NHib 附带了一些属性(或者现在可能是 NHib contrib),您可以用来装饰类和类属性.我猜这些早于 FNH,但不确定.

By mapping attributes, I don't mean hbm files; there are apparently attributes that come with NHib (or maybe NHib contrib these days) that you use to decorate your class & class properties. I'm guessing these pre-date FNH, but not sure.

推荐答案

我个人更喜欢自己创建 hbm.xml 文件.我使用过 Fluent,但我只是喜欢自己处理这样的事情.但是,我还没有遇到任何无法使用 Fluent 的映射...

I personally prefer to create the hbm.xml files myself. I've used Fluent, but I just like managing the nitty gritty myself for things like this. However I've not run into any mappings that I haven't been able to get working with Fluent though...

据我了解,Fluent nHibernate 实际上会根据您的设置在后台创建一个 hbm.xml 文件,然后 nHibernate 会使用该文件...所以 Fluent 本身正在创建映射,我认为只是创建手动的 hbm.xml 在技术上会给你更多的灵活性和访问映射文件的细微差别......

It is my understanding that Fluent nHibernate actually creates an hbm.xml file in the background based on your settings that is in turn used by nHibernate... so being that Fluent is itself creating the mappings, I would argue that just creating the hbm.xml manually would technically give you more flexibility and access to the nuance of the mapping file...

我认为两者都有相似的学习曲线,所以如果你打算费心学习 Fluent 本身会创建 hbm.xml 文件,为什么不首先学习如何自己创建该死的 hbm.xml 文件并跳过中间人!

I think that there is a similar learning curve for both, so if you are going to bother learning Fluent that itself creates hbm.xml files, why not just learn how to create the damn hbm.xml files yourself in the first place and skip the middle man!

除非您快速连续地进行许多项目,否则实际映射数据库的行为只是您在特定项目上所做的实际工作的一部分.

Unless you are doing MANY MANY projects in rapid succession, the act of actually mapping your database is only a fragment of the actual work you are doing on a particular project.

  • 马克斯·席林

这篇关于NHibernate 映射属性与流畅的 NHibernate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆