Code example:
DBModel curDB = new DBModel(); string RequestsDBPath = saveDir + @"RequestsDB.xml"; if (!File.Exists(RequestsDBPath)) { PersonClass person1 = new PersonClass("Π‘Π΅ΡΠ²Π΅ΡΠ½ΡΠΉ", "ΠΡΠ°Π±", "Π£ΡΠΈΠ»ΠΈΡΠΎΠ²ΠΈΡ", "OUP_2"); PersonClass person2 = new PersonClass("ΠΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»ΡΡΠΊΠΈΠΉ", "Π’ΡΠ»Π΅Π½Ρ", "Π€Π»ΡΠ΄ΠΈΠ»ΠΎΠ²ΠΈΡ", "IT_D112"); DataRow row = curDB.Requests.NewRow(); row["Id"] = 1; row["SM Id"] = "SR366312"; row["Desctription"] = "TestDesc"; row["Initiator"] = null; row["Worker"] = null; row["Status"] = "InProgress"; row["Creation Date"] = DateTime.Now; row["Changing Date"] = DateTime.Now.AddMonths(1); curDB.Requests.Rows.Add(row); curDB.Persons.Rows.Add(person1); curDB.Persons.Rows.Add(person2); curDB.WriteXml(RequestsDBPath, XmlWriteMode.IgnoreSchema); on curDB.Persons.Rows.Add (person1); I get an exception about the inadmissibility of null values ββin the FIO (Table Key) parameter;
public class PersonClass { public string SecondName; public string Name; public string ThirdName; public string FIO; public string Location; public PersonClass() { } public PersonClass(string SecondName, string Name, string ThirdName, string Location) { this.Name = Name; this.SecondName = SecondName; this.ThirdName = ThirdName; FIO = string.Format(@"{0} {1} {2}", SecondName, !string.IsNullOrEmpty(Name) ? Name.Substring(0, 1) : null, !string.IsNullOrEmpty(ThirdName) ? ThirdName.Substring(0, 1) : null).Trim(); this.Location = Location; } Upd: Wrote converter PersonClass => DataRow
public System.Data.DataRow toDataRow() { var row = MainWindow.curDB.Persons.NewRow(); row["Name"] = Name; row["SecondName"] = SecondName; row["ThirdName"] = ThirdName; row["FullName"] = FullName; row["Location"] = Location; return row; } curDB.Persons.Rows.Add(person1.toDataRow()); 
