开发者

Is there an attribute that will implicitly assume all members of a class that has a DataContract is a datamember?

开发者 https://www.devze.com 2023-02-15 00:12 出处:网络
Instead of having to specify [DataMember] for every member, is there a sort of attribute that can just assume it is a datamember?

Instead of having to specify [DataMember] for every member, is there a sort of attribute that can just assume it is a datamember?

I have a class with a lot of members that I have 开发者_StackOverflow中文版to serialize into a web service.


You could use [Serializable] instead, but it's going to cause you trouble in the future for versioning. Basically giving up [DataMember] means you can't explicitly control serialization order for members of your contract, which means adding a new member can easily break existing clients (because of the default WCF behavior of ordering members in alphabetical order instead of order of declaration).

0

精彩评论

暂无评论...
验证码 换一张
取 消