What is the format of the DataContractAttribute.Namespace Property?

烂漫一生 提交于 2019-12-06 20:52:35

It's an XML Namespace. Those can either be in the urn: format or they can be URLs.

Here are some additional suggestions from MSDN:

  • The namespace can be any string
  • but is traditionally a Uri representative of the company or application domain
  • and includes a year and month to support versioning scenarios.
  • For DataContracts, the namespace is often similar to the ServiceContract namespace
  • but uses using a “schemas” uri section

Example Service Contract with Namespace

[ServiceContract(Namespace="urn:CompanyName/ApplicationName/YYYY/MM")]
[ServiceContract(Namespace="urn:BigFont/EmailSystem/2014/03")]

Example Data Contract with "Schema" Segment in Namespace

[DataContract(Namespace="urn:CompanyName/Schema/YYYY/MM")]
[DataContract(Namespace="urn:BigFont/Schema/2014/03")]

Thank you to John Saunders or getting me started.

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