.NET XmlSerializer and multiple references to the same object

前端 未结 5 605
你的背包
你的背包 2021-01-05 04:52

My repository has List, List and List where an Enrolment has Enrolment.Student and Enrol

5条回答
  •  萌比男神i
    2021-01-05 05:44

    How does this sound as a solution:

    1. XMLIgnore each secondary reference ie Enrolment.Student & Enrolment.Course
    2. create a property for each secondary reference that is used to serialize/deserialize a foreign key for that reference instead - Prefix with XML_FK. eg XML_FK_Student & XML_FK_Course
    3. Create a method XML_FinalizeDeserialization that is called after deserialization to load the references using those foreign key properties.

提交回复
热议问题