开发者

Is there an attribute that will implicitly assume all members of a class that has a DataContract 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜