SubSonic - 我如何创建我的业务逻辑层

发布于 2024-09-26 08:25:03 字数 236 浏览 0 评论 0原文

我是亚音速新手,通常这是编程,我通常从 rad 角度进行开发,因此使用 Visual Studio 数据集设计器,但我想开始考虑开发他们的方法。

我从未使用过业务逻辑层,(顽皮)通常我的代码背后负责验证以及一般页面级验证。

我如何生成我的业务逻辑,我是否创建我的类之一的部分类,然后将业务逻辑添加到其中?这看起来怎么样?所以我有一个想法。

任何例子或建议将不胜感激。

谢谢丹

Im new to subsonic and generally this was of programming, i usually develop from a rad perspective so using the visual studio dataset designer, but i wanted to start looking at developing n teir approach.

Ive never used a business logic layer, (naughy) normally my code behind takes care of validation so to speak aswell as general page level validation.

How can i generate my business logic, do i create a partial class of one of my classes and then add the business logic into this? and how would this look? just so i have an idea.

Any exmaples or advice would be greatly appreciated.

Thanks

Dan

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

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

发布评论

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

评论(1

黑色毁心梦 2024-10-03 08:25:03

SubSonic 的最大问题是它从数据库表生成类,两者之间存在一一对应的关系。这使得 SubSonic 生成的类非常不适合用作业务对象,因为它将您的业务层非常直接地与数据库结构联系起来。这是一件的事情(无论如何,在我想到的几乎所有场景中)。

SubSonic 是一个查询工具,仅此而已。它肯定不是 ORM。

考虑到这一点,我认为创建业务逻辑层的正确方法是编写自己的业务类,并编写存储库类来管理数据的加载和存储。但仅在 Repository 类内部使用 SubSonic 来处理将数据实际保存到数据库的操作。

如果您在整个项目中使用 SubSonic 生成的类,您会发现您很可能做错了,并且对数据库模式的第一个重大更改将很好地说明这一点(或..不太好)。

事实上,我建议快速学习一个真正的 ORM,比如 NHibernate 或实体框架。它们使您在快乐之路上走得更远,而 SubSonic 仍然需要人们自己完成大部分数据层实现。

The big gotchya with SubSonic is that it generates classes from database tables, there is a 1-to-1 correspondence between the two. That makes the classes SubSonic generates quite unsuitable for use as business objects, because it would tie your business layer very directly to your database structure. This is a bad thing (in nearly all scenarios that come to my mind, anyway).

SubSonic is a query tool and little more. It most certainly is not an ORM.

With that in mind, I believe the correct way to create a Business Logic Layer is to write your own business classes, and write Repository classes to manage loading and storing the data. But use SubSonic only internally to the Repository classes to handle the actual persisting of your data to the database.

If you use the SubSonic generated classes throughout your project you will find you are most likely doing it wrong, and the first significant change to your DB schema will illustrate that nicely (or .. not nicely).

In fact, I would recommend quickly moving into learning a real ORM like NHibernate or Entity Framework. They bring you much farther down the Happy Path, whereas SubSonic still requires one to do much of the Data Layer implementation themselves.

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