How to store multiple classes data into XML file using wcfservice?

Posted by Mandlaa under WCF on 7/21/2014 | Points: 10 | Views : 517 | Status : [Member] | Replies : 2
This is my code
public void Add(Employee newEmployee)
{
XDocument doc = XDocument.Load(HttpContext.Current.Server.MapPath("StudentDB.xml"));
//doc.Element("NewEmployees");
empList.Add(new Employee
{
EmpNo = newEmployee.EmpNo,
EmpName = newEmployee.EmpName,
DeptName = newEmployee.DeptName,
AllDepart = new List<Department> { new Department() { DeptNo = newEmployee.AllDepart[0].DeptNo, Dname = newEmployee.AllDepart[0].Dname, Location = newEmployee.AllDepart[0].Location } },

AllSales = new List<Sales> { new Sales() { SName = newEmployee.AllSales[0].SName, Orders = new List<Order> { new Order() { Oid = Convert.ToInt32(newEmployee.AllSales[0]), OName = "ebay" } } } },
Purchages =new List<Purchage> { new Purchage () { Id=Convert.ToInt32(newEmployee.Purchages[0]),IName=newEmployee.Purchages[0].ToString()}}

});
doc.Save(HttpContext.Current.Server.MapPath("StudentDB.xml"));
}

where is mistake in my code above.




Responses

Posted by: Vuyiswamb on: 7/22/2014 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
Do you get an error "?

Thank you for posting at Dotnetfunda
[Administrator]

Mandlaa, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Mandlaa on: 7/22/2014 [Member] Starter | Points: 25

Up
0
Down
How to add that list values to Xml document object?

Mandlaa, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response