I am populating an XML structure (using VB.NET) to pass to a web service. Here is how one piece of the structure is filled, and the rest of the structure is filled in a similar manner:
Private Shared Function GetSpecialties(ByVal specialties As System.Data.Linq.EntitySet(Of Provider.provider_specialty)) As XElement
Return _
New XElement( _
"provider_specialties", _
From s In specialties _
Select New XElement( _
"provider_specialty", _
New XElement("external_provider_specialty_id", s.external_provider_specialty_id), _
New XElement("record_type_id", s.record_type_id), _
New XElement("effective_date", s.effective_date), _
New XElement("termination_date", s.termination_date), _
New XElement("specialty_code", s.specialty_code)))
End Function
Some pieces of the structure can contain up to 30 elements. Each record takes about .1 seconds to create, and it needs to create about 35,000 records, so the whole process takes about an hour.
Is there a quicker way to fill an XML structure like this?