I want to create a XML file to store data using a dataset in c#. The classes are as follows
public class Person
{
  [Key]
  public string id { get; set; }
  public string name { get; set; }
  public virtual ICollection<Dependant> dependants { get; set; } 
}
public class Dependant
{
   public string name { get; set; }
   public string email { get; set; }
}
The final XML file that is produced should be
  <db>
    <Person>
      <id>1</id>
      <name>John</name>
      <dependants>
        <dependant>
         <name>test1</name>
         <email>test1</email>
        </dependant>
        <dependant>
         <name>test2</name>
         <email>test2</email>
        </dependant>
      </dependants>
    <Person>
  <db>
The requirement is to use it like an database and the data should be added using
Dataset db = new Dataset();
List<Dependant> dpList = new List<Dependant>();
Dataset.PersonRow pr = new Dataset.PersonRow();
pr.name = "name";
pr.id = "pr1";
Dependant dp = new Dependant();
dp.name = "dp1";
dp.email = "dp1";
dpList.Add(dp);
dp.dependants = dpList;
db.Person.AddNewPersonRow(dp);
db.AcceptChanges();
db.WriteXML("localData");
This is the structure that should be followed according to the lecturer.
I'm having the problem in creating the datatable as I do not know the datatypr that should be used for the list, when creating the datatable.
How can i acheive this?
Im new to c# so any help would be great!
 
    