I want to map a xml file to a SQL Server table.
This is what I've done so far:
XmlTextReader reader = new XmlTextReader("navetout.xml");
XmlNodeType type;
while (reader.Read())
{
type = reader.NodeType;
if(type == XmlNodeType.Element)
{
}
}
//using Entity framework
static void writeToDatabase()
{
BumsEntities _bums = new BumsEntities();
_bums.Seamen.Add(new Seamen
{
PersonalIdentityNumber = "",
ReferedCivicRegistrationNumber = "",
UnregistrationReason = "",
UnregistrationDate = "",
MessageComputerComputer = "",
GivenNameNumber = "",
FirstName = "",
MiddleName = "",
LastName = "",
NotifyName = "",
NationalRegistrationDate = "",
NationalRegistrationCountyCode = "",
NationalRegistrationMunicipalityCode = "",
NationalRegistrationCoAddress = "",
NationalRegistrationDistributionAddress1 = "",
NationalRegistrationDistributionAddress2 = "",
NationalRegistrationPostCode = "",
NationalRegistrationCity = "",
NationalRegistrationNotifyDistributionAddress = "",
NationalRegistrationNotifyPostCode = "",
NationalRegistrationNotifyCity = "",
ForeignDistrubtionAddress1 = "",
ForeignDistrubtionAddress2 = "",
ForeignDistrubtionAddress3 = "",
ForeignDistrubtionCountry = "",
ForeignDate = "",
BirthCountyCode = "",
BirthParish = "",
});
_bums.SaveChanges();
}
The code above is the database columns. What I want to be able to do is to load the xml file and insert the tags into the columns. The problem is that I don't know how to "translate" the xml tags to the database columns.. Can anyone help me out?