WCF契约知域

编程入门 行业动态 更新时间:2024-10-27 10:23:00
本文介绍了WCF契约知域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我有四个项目:
1.业务项目,定义了我的项目的业务登录.
2. 定义合约接口和DTO的服务合约项目.
3. 定义服务实现的服务实现项目.
4. 带有使用该服务的 svc 文件的 Web 应用程序.

I have four projects:
1. Business project that defines the business login of my project.
2. Service contract project that defines a contract interface and DTOs.
3. Service implementation project that defines an implementation to the service.
4. Web application with svc file that uses the service.

理论上:
A. 合同项目不得引用任何人.
B. 服务实现应参考合同项目和域.
C. Web 应用程序应仅引用合同和实施项目.

Theoretically:
A. The contract project should reference to no one.
B. The service implementation should reference the contract project and the domain.
C. The web application should reference only the contract and implementation project.

我有这样的服务:

AccoundData GetAccount(AccountTypeEnum type);

问题是在域中定义了AccountTypeEnum,这样合约和web应用程序就应该有域的引用..但这是我们试图阻止的..那么如何我阻止了知道"域的合同?

The problem is that AccountTypeEnum defined in the domain, so that the contract and the web application should have reference to the domain.. But this is what we are trying to prevent.. So how can I prevent from the contract of "knowing" the domain?

推荐答案

在这种情况下,您的合同必须使用不同的枚举/DTO,并且您的服务实现必须在合同枚举和域枚举之间进行转换.

In such case you contract must use different enum / DTO and your service implementation must translate between contract enum and domain enum.

这篇关于WCF契约知域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-26 18:54:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1141039.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:契约   WCF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!