gpt4 book ai didi

wcf - 在 WCF 服务之间共享 DTO 对象

转载 作者:行者123 更新时间:2023-12-04 19:23:39 25 4
gpt4 key购买 nike

我什至在问之前就觉得这是一个愚蠢的问题,但是我的大脑现在运转得不太好。我有两个 WCF 服务“CountryService”和“FloristService”。

现在 CountryService 有以下方法:

IList<CountryDTO> GetAllCountries();

此外, FloristService 有一个方法:
bool AddFlorist(FloristDTO florist);

到目前为止一切都很好,但问题是 FloristDTO 引用了 CountryDTO,即
    public  string Address1 { get; set; }
public string Address2 { get; set; }
public string Address3 { get; set; }
public string City { get; set; }
public string Postcode { get; set; }
public CountryDTO Country { get; set; }
public string Name { get; set; }

这很好,但是如果我将服务代理生成工具与 Visual Stuidos 一起使用(即添加引用 > 添加服务引用),那么我会创建两个版本的 CountryDTO,即 FloristService.CountryDTO 和 CountryService.CountryDTO。

现在我可以想出一些方法来克服这个问题,但似乎没有一个是正确的。我想知道“正确”的方法是什么,我可以用代理生成工具做些什么来让它共享常见的 DTO?

干杯,克里斯

最佳答案

关于wcf - 在 WCF 服务之间共享 DTO 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1637218/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com