Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<ul> <li>XML Serialization to a StudentDTO object. </li> <li>StudentDTO to Student mapping. </li> <li>Mapped student to be saved in DB.</li> </ul> <p>The StudentDTO is recommended here as you want to decouple Student class from the XML definition from web. If at all the XML definition changes you would only have to change DTO and not the Student implementation.</p> <p>Potential non production code:</p> <pre><code>[XmlElement] public class StudentDTO { [XmlElement] public string StudentName {get;set;} } [XmlElement] public class StudentsDTO : List&lt;StudentDTO&gt; { } public class Student { public string Name {get;set;} } //Ideally on big System, Mapper class would be a generic on the lines of Mapper&lt;Source,Target&gt; //Mapper&lt;StudentDTO,Student&gt; and based on some rules it would do mapping. public class StudentDTOToStudentMapper { public Student GetStudentForDTO(StudentDTO dto) { //create object of student // Map corresponding property of StudentDTO to Student // e.g. StudentName to Name } } public class Client { public static void Main(DBHelper dbHandler, XMLSerialiser seriliaser, WebService serviceToCall,StudentDTOToStudentMapper mapper ) { // XmlDocument/Object obj = serviceToCall.GetStudentsXML(); // StudentsDTO students = Seriliaser.Deserialise(XML); // IEnumerable&lt;Student&gt; studentObjects = from eachDTO in students // select mapper.GetStudentForDTO(eachDTO) // bool IsSaved = dbHandler.Save(students); // Based on IsSaved show the status. } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload