私はclass A
それから派生していSystem.Data.Objects.DataClasses.EntityObject
ます。を使用してシリアル化しようとすると
var a = new A();
DataContractJsonSerializer serializer = new DataContractJsonSerializer(a.GetType());
serializer.WriteObject(Response.OutputStream, a);
エラーが発生します
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 'True'. It is not possible to have required data members on IsReference classes. Either decorate 'TestController+A._Id' with OptionalFieldAttribute, or disable the IsReference setting on the appropriate parent class.
でフィールドを飾ってOptionalFieldAttribute
も
The type 'TestController+A' cannot be serialized to JSON because its IsReference setting is 'True'. The JSON format does not support references because there is no standardized format for representing references. To enable serialization, disable the IsReference setting on the type or an appropriate parent class of the type.
EntityObject
クラスを変更できません。A_Bag
クラスをクラスとまったく同じように作成しA
、それを埋めて、代わりにシリアル化することA
を考えましたが、もっとエレガントな方法があると思います。
どうすればいいのか提案してもらえますか?