连接两个对象以进行自定义序列化?
在 Framework 4 上的 C# 中,我有一个 List 和 List。可以通过 JoinId 属性将它们连接起来。 ParentObj 将有 2 个 ChildObj 匹配项,有时有 10 个。
我想将每个 Parent 和所有 Children 序列化为单个 XML 实体。我很难弄清楚从哪里开始,因为我还需要以自定义方式序列化对象。在这种情况下我可以使用 Linq-to-XML 来正确编写每个对象吗? Xml序列化器?没有把握。
谢谢。
In C# on Framework 4, I have a List and List. They can be joined on the JoinId property. ParentObj will have 2 ChildObj matches, sometimes 10.
I would like to take each Parent and all Children and serialize to a single XML entity. I am having a hard time figuring out where to start, because I also need to serialize the objects in a custom way. Can I use Linq-to-XML in this case to get each object written correctly? XmlSerializer? Not sure.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的。这正是您所需要的。 A基本示例。
这也可行,但这种方法比较旧,我认为在这种情况下不太合适而且更复杂。
Yes. This is exactly what you need. A basic example.
This will work too, but this approach is older and I think it is less appropriate and more complicated in this case.