WCF:作为DataContract的接口(使用Entity Framework作为这些接口的实现) [英] WCF: Interfaces as DataContract (using Entity Framework as implementation of these Interfaces)

查看:83
本文介绍了WCF:作为DataContract的接口(使用Entity Framework作为这些接口的实现)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们是否可以将接口公开为WCF服务的DataContract或Poco类是唯一的方式,当数据访问项目将使用EntityFramework后面的单独层级托管时现场?

Can we expose an interface as DataContract of WCF service or Poco class is the only way, when data access project will be hosted on separate tier using EntityFramework behind the scene?

推荐答案

您需要在界面上公开具体类型。请记住,WSDL必须能够完整地描述所有数据,并且客户端(假设.Net)必须能够构建其中一个对象。

You will need to expose a concrete type over the interface. Keep in mind the WSDL has to be able to fully describe all of the data, and the client (assuming .Net) has to be able to construct one of the objects.

正常的做法是创建一个DTO类,除了通过网络传输数据之外什么都不做。在您的服务中,使用EF POCO中的数据填充DTO。在客户端,取出DTO并将数据复制到客户实际需要的任何内容。

The normal practice is to create a DTO class that does nothing but transfer data over the wire. In your service, populate the DTO with data from your EF POCO. On the client side, take that DTO and copy the data over to whatever your client actually needs.


这篇关于WCF:作为DataContract的接口(使用Entity Framework作为这些接口的实现)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆