Reputation: 4386
How how can I do this:
XDocument xDocument = new XDocument(new XElement("SqlInstall",
new XElement("Catalogs",
new XElement("Install"),
foreach (var item in packagedProduct.Installs)
{
new XElement("File ")..
}
))));
It complains about the foreach loop within the Linq statement with "invalid expression term foreach"
Upvotes: 3
Views: 1376
Reputation: 21226
The foreach loop should be rewritten like that:
packagedProduct.Installs.Select( item => new XElement("File ").. );
Upvotes: 7