使用 Fluent NHibernate 进行架构版本控制

发布于 2024-12-14 08:34:43 字数 1042 浏览 3 评论 0原文

我尝试阅读以前的一些答案,但据我所知,尚不清楚其中任何一个是否适用于我的情况。大多数问题似乎都涉及网络应用程序。我认为我最好先陈述我的要求并从那里开始,而不是尝试对针对不同情况的建议进行逆向工程。我本质上是在问两个问题:(

  • 流畅的)NHibernate 支持什么,原则上可以让我实现这些要求?如果可能的话,我更愿意使用 Fluent API;
  • 我必须自己写什么才能开发出可行的解决方案?

概括地说,要求如下:

  • 我想要做的是使用 FNH 来保存和补充桌面应用程序的模型,该应用程序的使用模型与 MS Office 大致相同 - 也就是说,工作保持为自我状态- 包含加载到应用程序本地实例中的文件。
  • 应用程序的当前版本必须能够从所有以前版本中导入文件,并保留除向用户声明不支持的信息之外的所有信息; “导入”的意思是“将文件 A 中包含的模型信息转录到新文件 B 中,以便文件 B 与当前版本完全兼容,除了声明不支持的版本之外。”
  • 应用程序的当前版本必须能够导出当前模型,以便仅与应用程序的先前主要版本的最新版本兼容。不需要提供与先前主要版本的任何旧版本的遗留兼容性。
  • 产品的性质使得文件格式的更新相当频繁——目标是能够在必要时每六个月左右向用户发布一次,作为一个大概数字,并且在开发过程中的更改比这要频繁得多。

我不反对编写代码来处理这个问题,前提是:

  • 编码不会花费过多的时间来对模式进行任意复杂的更改;
  • 我可以通过单元测试调用FNH API来验证版本之间的翻译是否完成;
  • 我可以验证任何给定的模型都会在版本之间正确往返,并且只会丢失向用户声明在产品版本之间不受支持的数据;

那么,总结一下:

  • Fluent NHibernate 提供了什么(如果有的话)来支持这种用例?
  • 这些要求是否可以很容易地满足,或者我是否必须使它们更加具体和受到限制?
  • 关于自己编码,我应该调查什么?

I've tried reading some previous answers but it's not clear whether or not any of them apply to my situation, as far as I can see. Most of the questions seem to refer to web applications. I figure I'm better off stating my requirements and going from there instead of trying to reverse-engineer advice meant for a different situation. I'm essentially asking two questions:

  • What does (Fluent) NHibernate support that would, in principle, allow me to achieve the requirements? I'd prefer to use the Fluent API if possible;
  • What am I going to have to write myself to develop a working solution?

Broadly, the requirements are as follows:

  • What I'd like to do is use FNH to persist and rehydrate models for a desktop application that would have roughly the same usage model as MS Office, for example - that is, work is kept as self-contained files which are loaded into a local instance of the application.
  • The current version of the application must be able to import files from all previous versions and preserve all information except that which is declared to the user to be unsupported; by 'import' I mean 'transcribe the model information contained in file A into new file B such that file B is fully compatible with the current version, beside that which is declared to be unsupported.'
  • The current version of the application must be able to export a current model to be compliant with only the most recent issue of the previous major version of the application. It is not required to supply legacy compatibility with any older revisions of the previous major version.
  • The nature of the product is such that updates to the file format happen fairly frequently - aim to be able to release to the user every six months or so if necessary as a ballpark figure, and are changed in development much more frequently than that.

I have no objection to writing code to handle this, provided that:

  • The coding does not take an inordinate amount of time for arbitrarily complicated changes to the schema;
  • I am able to verify whether or not the translation between versions is complete by calling the FNH API through unit tests;
  • I can verify that any given model will round-trip correctly between versions and only lose data which is declared to the user to be unsupported between product versions;

So, to summarise:

  • What, if anything, does Fluent NHibernate supply to enable this kind of use-case?
  • Can the requirements be readily satisfied as they are, or will I have to make them more specific and constrained?
  • What should I investigate as to coding myself?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

染年凉城似染瑾 2024-12-21 08:34:43

我建议使用文档数据库,例如 RavenDB、MongoDb 等,来完成您想要做的事情。我认为这些比尝试强制 RDBMS(sql 服务器、oracle 等)以及因此 nHibernate 做一些它不太擅长的事情更适合。并不是说它不能,但你最终会跳过各种障碍来完成你所要求的事情。

需要注意的一件事是 Fluent Nhibernate 仅将 Fluent API 置于 nhibernate 的类映射之上。

I would suggest using a document database, something like RavenDB, MongoDb etc, for what you are trying to do. I think these would be a better fit than trying to force a RDBMS (sql server, oracle etc) and consequently nHibernate to do something that its not all that good at. not to say that it can't, but you will end up jumping through all sort of hoops to accomplish what you are asking.

One thing to note is that Fluent Nhibernate only puts a Fluent API over the Class Mapping of nhibernate.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文