私のコード:
var myList = xDoc.Descendants("localita").Select(n => new
{
ID = n.Element("id").Value.ToString(),
Localita = n.Element("nome").Value.ToString(),
Lat = n.Element("lat").Value.ToString(),
Lng = n.Element("lon").Value.ToString(),
MeteoOggi = new MeteoGiorno()
{
Min = n.Descendants("previsione").First().Element("temp_perc").Value.ToString(),
Max = n.Descendants("previsione").First().Element("temp").Value.ToString(),
DescrizioneTempo = n.Descendants("previsione").First().Element("desc_tempo").Value.ToString(),
Precipitazioni = n.Descendants("previsione").First().Element("prec").Value.ToString(),
VentoDirezione = n.Descendants("previsione").First().Element("v_dir").Value.ToString(),
VentoIntensita = n.Descendants("previsione").First().Element("v_int").Value.ToString(),
Pressione = n.Descendants("previsione").First().Element("press").Value.ToString(),
ZeroTermico = n.Descendants("previsione").First().Element("zerot").Value.ToString(),
Immagine = n.Descendants("previsione").First().Element("id_tempo").Value.ToString()
}
});
しかし、ご覧n.Descendants("previsione").First()
のとおり、 Class の値を設定するたびに「検索」されますMeteoGiorno
。私の例でそのノードへの参照のようなものを入れることはできますか?