Database Reference
In-Depth Information
Directory.GetFiles(@"c:\Load_XML_Files", "temp" );
foreach (string filename in dirs)
{
/***
* De-serialize the XML into the objects
* *****/
EventMessage details =
DeserializeEventMessage(filename);
PaymentDAL payDAL = new PaymentDAL();
/*****
* Save to the database
* *****/
payDAL.writeEventMsg(details);
}
}
static public EventMessage
DeserializeEventMessage(string filename)
{
XmlSerializer serializer = new
XmlSerializer(typeof(EventMessage));
using (TextReader reader = new
StreamReader(filename))
{
EventMessage eventMsg =
(EventMessage)serializer.Deserialize(reader);
return eventMsg;
}
}
}
After we read and write data from files, we can process them as messages or save them to
the database. This is a simple example of loading messages from files into the database
using reflection and Entity Framework.
Search WWH ::




Custom Search