customers =
(
from c in xDoc.Descendants("customer")
orderby c.Attribute("CustomerID").Value
select new Customer
{
ID = c.Attribute("CustomerID").Value,
CompanyName = c.Attribute("CompanyName").Value,
ContactName = c.Attribute("ContactName").Value,
ContactTitle = c.Attribute("ContactTitle").Value,
Address = c.Attribute("Address").Value,
City = c.Attribute("City").Value,
State = c.Attribute("State").Value,
ZIPCode = c.Attribute("ZIPCode").Value,
Phone = c.Attribute("Phone").Value
}
).ToList();
答案 0 :(得分:2)
Dim customers = (From c In xDoc.Descendants("customer")Order By c.Attribute("CustomerID").Value
Select New Customer() With { _
.ID = c.Attribute("CustomerID").Value, _
.CompanyName = c.Attribute("CompanyName").Value, _
.ContactName = c.Attribute("ContactName").Value, _
.ContactTitle = c.Attribute("ContactTitle").Value, _
.Address = c.Attribute("Address").Value, _
.City = c.Attribute("City").Value, _
.State = c.Attribute("State").Value, _
.ZIPCode = c.Attribute("ZIPCode").Value, _
.Phone = c.Attribute("Phone").Value _
}).ToList()