【发布时间】:2025-12-11 05:10:02
【问题描述】:
我被这个简单的问题困住了。在我的控制台应用程序中,我想使用 wcf 服务。所以我将网络引用添加到项目并调用它。就是这样。
但为什么我看到了一些特别是使用 RESTSHARP 的示例,它们从不添加 Web 参考。他们只是使用所谓的“DTO”通过服务返回对象并使用它。
我希望有人可以为我澄清这些概念。 DTO 是否在 WCF 内部使用?
样本:
private static List<ApplicationDTO> features;
RestClient client = new RestClient("http://" + baseUrl + "/FacilityData.svc");
var request = new RestRequest(Method.GET);
request.Resource = "/GetFeatures";
request.Parameters.Clear();
request.AddParameter("Id", 888);
var response = client.Execute(request);
features = JsonConvert.DeserializeObject<List<ApplicationDTO>>(response.Content);
【问题讨论】:
-
我通过这个链接理解了这个概念:DTO & POCO