我正在尝试将对象序列化为Azure移动服务. 该对象包含一个第二个对象的数组,该数组也应该被序列化. [DataContract()]class ObjectA{ [DataMember(Name= "id")] public int Id { get; set; } [DataMember(Name = "inf
该对象包含一个第二个对象的数组,该数组也应该被序列化.
[DataContract()] class ObjectA { [DataMember(Name= "id")] public int Id { get; set; } [DataMember(Name = "info")] public string info{ get; set; } [DataMember(Name = "collectionOfB")] public ObjectB[] myArrayOfB{ get; set; } } [DataContract()] class ObjectB { [DataMember(Name= "id")] public int Id { get; set; } [DataMember(Name = "info")] public string info{ get; set; } }
我已经正确加载了两个表,并且可以在每个表中插入单个项目.
但是,当我在objectA的表上调用InsertAsync方法时,我收到一个错误
Cannot serialize member 'myArrayOfB' of type 'namespace.ObjectB[]' declared on type 'ObjectA'
有什么想法我需要做些什么才能解决这个问题?
移动服务不支持阵列的序列化.这里有两篇好文章展示了你如何支持这个:> http://blogs.msdn.com/b/carlosfigueira/archive/2012/08/30/supporting-arbitrary-types-in-azure-mobile-services-managed-client-simple-types.aspx
> http://blogs.msdn.com/b/carlosfigueira/archive/2012/09/11/supporting-complex-types-in-azure-mobile-services-clients-implementing-1-n-table-relationships.aspx