Hi I have a number of related issues but I will break the questions down into seperate posts.
My XML is <Person>.....<Skills><Skill>Resus<Skill></Skills></Person>
My code is :
var products1 = from prd in xDoc.Descendants("Person")
select new BusinessEntityLayer.Personnel
{
PayrollNo = (String)prd.Element("PayrollNumber"),
FirstName = (String)prd.Element("Name"),
LastName = (String)prd.Element("Surname"),
StreetAddress = (String)prd.Element("StreetAddress"),
Suburb = (String)prd.Element("Suburb"),
HomePhone = (String)prd.Element("HomePhone"),
MobilePhone = (String)prd.Element("MobilePhone"),
PagerNumber = (String)prd.Element("PagerNumber"),
Email = (String)prd.Element("Email"),
RecordType = (String)prd.Element("RecordType"),
Skills = (List<String>)prd.Element("Skills")
My Personnel class is strongly typed. It all works perfectly apart from the Skills collection. Skills is List<Skill>
but my code won't compile with an error - XLInq.Element
to Generic.List
...nor can I use String[]
(refactoring my business class) as I get the same result.
What strategies do people use here?