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
में कनवर्ट करने का प्रयास किया लेकिन कुछ भी काम नहीं किया। मेरी मदद करो, दोस्तों।अंतर्निहित रूप से प्रकार 'System.Linq.IQueryable <int>' से 'int' को परिवर्तित नहीं कर सकता है?
धन्यवाद
क्या आपके उदाहरण के लिए और कुछ है? ऐसा लगता है कि लूप के हर पुनरावृत्ति के बाद सिटी ऑब्जेक्ट को हमेशा त्याग दिया जाएगा? – R0MANARMY