I’m trying to write a WCF Web service that will return my data as JSON so I can call it from some client script.
I know I need to decorate any classes I want to return from the Web Methods in a [DataContract] attribute and then any Members in a [DataMember]. That in mind I want to return entity types so I went to the Entity ObjectContext classes.
However when I look at the .edmx file I can see that the classes have been decorated like so…
[EdmEntityTypeAttribute(NamespaceName="PteDotNetModel", Name="AssocFile")]
[Serializable()]
[DataContractAttribute(IsReference=true)]
public partial class AssocFile : EntityObject
When I then try and add [DataContract] I get an error saying I can’t have duplicated attributes. I’m confused whilst they are similar they are clearly different no?
The second part of my question is how I return entity types over a WCF service?
The two attributes are the same; the trailing “Attribute” can be excluded. From MSDN: