我需要認識到,這樣的結構:屬性與元素DataContractSerializer的
Emplooyee:
- ID
- 名
- 姓
- 電子郵件
- 誕生日期
- 顧客
- ID
- 名稱
- 地址
- 電話
- 電子郵件
- 更多然後1000名員工
- 業務
- ID
- 名稱
- 說明
每一個員工可能有不止一個客戶,所有的數據應該存儲/使用XML序列化加載/從XML文件,業務領域應存儲在XML作爲屬性。
public class AllEntities
{
public AllEntities()
{
Create();
}
public List<Employee> allEmployees { get; set; }
public List<Customer> allCustomers { get; set; }
public List<Business> allBusiness { get; set; }
private void Create()
{
allCustomers = new List<Customer> { new Customer ("Company1", "Minsk", "1236547", "[email protected]", false),
new Customer("Company2", "Minsk", "7896589", "[email protected]", false)};
allBusiness = new List<Business> { new Business("Programming", "Short description"),
new Business("Desin", "Short description")};
allEmployees = new List<Employee> { new Employee("Alex", "Malash", "[email protected]", new DateTime(1990, 5, 9), allCustomers, allBusiness[0]),
new Employee("Ira", "Vashnko", "[email protected]", new DateTime(1990, 9, 1), new List<Customer> { allCustomers[0] }, allBusiness[1]),
new Employee("Igor", "Loshara", "[email protected]", new DateTime(1990, 1, 8), allCustomers, allBusiness[0])};
}
}
當我使用的DataContractSerializer,我不能創建屬性,當我使用XmlSerializer的,在deserializetion,也有在不同的員工同ojects(客戶)不匹配(有相同帶一些filds不同的對象)。
我可以嘗試什麼?
您可以嘗試使用XML序列化程序詢問您的問題。我們可能會幫助你。 – 2011-01-30 23:24:31