English 中文(简体)
数据周期
原标题:DataContractSerializer not serializing one property

当我编造以下类别时,由此产生的XML档案中遗漏了内容清单。

[CollectionDataContract(ItemName = "Widget")]
public sealed class StructurePage : List<Widget>, IEquatable<StructurePage>
{
    [DataMember]
    public int ContentPageId
    {
        get;
        set;
    }

    public StructurePage(){}

    public StructurePage(int pageId)
    {
        this.ContentPageId = pageId;
    }

    public bool Equals(StructurePage other)
    {
        return this.ContentPageId.Equals(other.ContentPageId);
    }
}
  1. Why is the property skipped when serializing and how to include it as XML element?
  2. Is it possible to include it in serialization as an XML attribute to the StructurePage element? Was looking for this around the net but could find any info on it, apparently with XmlSerializer there was XmlAttributeAttribute attribute but no such thing with DataContractSerializer.
最佳回答

http://social.msdn.microsoft.com/Forums/eu/wcf/thread/57eb195a-43a-47fe-8b1a-a9d23feb2df2”rel=“nofollow”http://social.msdn.microsoft.com/Forums/eu/wcf/thread/57eb195a-43a9fe-8b1a-a9dfeb2df

资料来源:统计局。

数据收集合同类别不能包含额外的数据成员。

希望这一帮助。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签