我们是否需要Ado.net实体Framework 2010中POCO类的DataContract属性 [英] Do we need DataContract attribute on POCO classes in Ado.net entity Framework 2010

查看:118
本文介绍了我们是否需要Ado.net实体Framework 2010中POCO类的DataContract属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在stackoverflow本身的某处读到,当我们使用Poco generator将POCO类用于WCF合约时,我们不需要使用DataContract和DataMember属性.WCF是否对您自动? .我不知道它是如何管理的.

I read somewhere in stackoverflow itself that when we use POCO classes for WCF contracts using Poco generator , we need not use DataContract and DataMember attributes.WCF do it auto for you? . I don't know how it manages this.

我创建了一个不使用这些属性的示例应用程序,并且能够在客户端生成这些实体并使用它们.我禁用了代理生成和延迟加载.

I created a sample application without using these attributes and I was able to generate those entities on client side and use them. I disabled proxy generation and Lazy loading.

我在这里错过了什么吗??真的不需要放置这些属性.

Am i missing anything here.? Is there really no need of putting these attributes.

推荐答案

您做得对.从WCF 3.5 SP1开始,不需要添加DataContract和DataMember属性.如果未使用属性,则带有公共getter和setter的所有属性都将被序列化.

You did it right way. Since WCF 3.5 SP1 it is not needed to add DataContract and DataMember attributes. If attributes are not used all properties with public getter and setter are serialized.

这篇关于我们是否需要Ado.net实体Framework 2010中POCO类的DataContract属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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