【发布时间】:2011-02-04 05:42:02
【问题描述】:
var cityList = from country in
doc.Element("result")
.Element("cities")
.Descendants("city")
select new {
Name = country.Element("name").Value,
Code = country.Element("code").Value,
CountryCode = int.Parse(country
.Element("countrycode")
.Value)
};
foreach(var citee in cityList)
{
City city = new City();
city.CountryID = from cnt in db.Countries
where cnt.DOTWInternalID == citee.CountryCode
select cnt.ID;
}
我在第二个查询中遇到错误,如本文标题所示。我尝试将int 转换为nullable int,但没有任何效果。帮帮我,伙计们。
谢谢
【问题讨论】:
-
您的示例还有更多内容吗?看起来 City 对象在每次循环迭代后都会被丢弃?
标签: c# linq iqueryable