public List<MyClassEntity> ExtractEmployee(...params here...){...SQL CONNECTION HERE AND SP TO RUN THE QUERY...
while (reader.Read()){ myList.Add(MapColumnsFromReader(reader));}return myList;}
private myClassEntity MapColumnsFromReader (SqlDataReader reader) { return new MyClassEntity { EmployeeID = Convert.ToInt32(reader[EmployeeID]), FirstName = reader[FirstName].ToString(), FamilyName = reader[FamilyName].ToString(), PastEmployerNames = reader[Employers].ToString(), YearPositionHeld = Convert.ToInt32(reader[YearPos]), RolesHeld = reader[Roles].ToString() }; }
Dataset:
EmpID FirstName FamilyName PastEmployer YearPosHeld RolesHeld123 John Adams Contoso Inc. 1994 Data Clerk123 John Adams Contoso Inc. 1995 Analyst 123 John Adams Taj Software 1995 Senior Analyst123 John Adams Taj Software 1995 Technical Specialist324 Mikel Borfed MicroShell Corp 1989 Data Analyst541 Greggy Dorsane Digital Media Ltd. 1998 Systems Analyst541 Greggy Dorsane Digital Media Ltd. 1998 Senior Systems Analyst541 Greggy Dorsane Digital Media Ltd. 1999 Supervisor541 Greggy Dorsane Digital Media Ltd. 1999 Senior Supervisor541 Greggy Dorsane Digital Media Ltd. 2001 Manager
DESIRED Serialized SOAP XML:
<Employees><employee><EmpId>123</EmpId><FirstName>John</FirstName><FamilyName>Adams</FamilyName> <PastEmployers> <EmployerName>Contoso Inc.</EmployerName> <YearPosHeld>1994</YearPosHeld> <RolesHeld>Data Clerk</RolesHeld> <EmployerName>Contoso Inc.</EmployerName> <YearPosHeld>1995</YearPosHeld> <RolesHeld>Analyst</RolesHeld> <EmployerName>Taj Software</EmployerName> <YearPosHeld>1995</YearPosHeld> <RolesHeld>SeniorAnalyst</RolesHeld> <EmployerName>Taj Software</EmployerName> <YearPosHeld>1995</YearPosHeld> <RolesHeld>Technical Specialist</RolesHeld> <PastEmployers></employee><employee><EmpId>541</EmpId><FirstName>Mikel</FirstName><FamilyName>Borfed</FamilyName> <PastEmployers> <EmployerName>Microshell Corp</EmployerName> <YearPosHeld>1989</YearPosHeld> <RolesHeld>Data Analyst</RolesHeld> <PastEmployers></employee>...other employees here......
</Employees>