业务对象是否应该知道其相应的合约对象

发布于 2024-10-01 13:48:21 字数 228 浏览 1 评论 0原文

我有一些业务对象和一些非常相似的相应数据契约对象,用于通过 WCF 服务通过网络获取数据。

我应该使用什么机制从业务对象获取填充的数据协定对象?

在理想的情况下,数据契约层应该了解业务层吗?

或者

业务层应该了解数据契约层吗?

或者

是否应该有另一个具有静态方法(如 GetDataContractFromBusinessObject)的映射层?

I have some business objects and some very similar corresponding data contract objects for getting data across the wire via WCF service.

What mechanism should I use to get populated data contract objects from business objects?

In an ideal world, should the data contract layer know about the business layer?

or

Should the business layer know about the data contract layer?

or

Should there be another mapping layer that has static methods like GetDataContractFromBusinessObject?

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

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

发布评论

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

评论(2

能怎样 2024-10-08 13:48:21

我非常喜欢你提到的“使用静态方法的映射层”技术。这样,您的业务对象和数据契约就不会相互依赖。

I am a big fan of the "mapping layer with static methods" technique you mention. Then, your business objects and data contracts don't depend on each other either way.

夜司空 2024-10-08 13:48:21

我经常会添加一个派生类来处理来自业务层中特定后备存储的数据消耗。

另一种选择是业务类可以理解的接口数据层表示。然后让您的数据层实现该接口。我更喜欢这种方法,因为让业务层与数据层的抽象版本交互然后让数据层理解您的业务对象要简单得多。

I often will add a derived class to handle data consumption from a specific backing store in my business layer.

Another option is to an interface data layer representation that the business class understands. And then have your data layer implement that interface. I prefer this method as it is much simpler to have you business layer interact with an abstracted version of your data layer then having your data layer understand your business objects.

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