How to serialize class that derives from class decorated with DataContract(IsReference=true)?
问题 I have class A that derives from System.Data.Objects.DataClasses.EntityObject . When I try to serialize using var a = new A(); DataContractJsonSerializer serializer = new DataContractJsonSerializer(a.GetType()); serializer.WriteObject(Response.OutputStream, a); I get error TestController+A._Id' is not marked with OptionalFieldAttribute, thus indicating that it must be serialized. However, 'TestController+A' derives from a class marked with DataContractAttribute and an IsReference setting of