Entity framework data contract

早过忘川 提交于 2019-12-05 23:33:36

As of .NET 3.5 SP1 - yes, the [DataContract] is no longer required.

If you omit it, then the class will be serialized like the XML serializer does: all public properties on your class will be serialized by default.

However: if you start using a [DataContract] on your class or a [DataMember] on one of your properties, then you must decorate all properties you want to serialize with a [DataMember].

So it's either : leave out those attributes entirely (use the default behaviour like the XML serializer uses), or then be specific and decorate the class with [DataContract] and every property you want to have serialized with [DataMember]. I prefer this second approach.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!