以下代码的等效 Linq to XML 是什么:
public List<listing> GetList()
{
List<listing> listings = new List<listing>();
if(File.Exists(this.XmlFilePath))
{
DataSet ds = new DataSet();
ds.ReadXml(this.XmlFilePath);
DataTable dt = ds.Tables["listing"];
for(int row = 0; row < dt.Rows.Count; row++)
{
listing listing = new listing();
listing.A = dt.Rows[row]["A"].ToString();
listing.B = dt.Rows[row]["B"].ToString();
listing.C = dt.Rows[row]["C"].ToString();
listing.D= dt.Rows[row]["D"].ToString();
listing.E = dt.Rows[row]["E"].ToString();
listings.Add(listing);
}
}
return listings;
}