在大部分的时候要在页面上显示字母和 国家页面 ,可以采用类中有类的方法,绑定reapter控件就可以
public static List<Letter_City> GetCitiesWithLetterByContinentID(short continentId)
{
string key = string.Format(SR.Cache_City_With_Letter_By_ContinentID, continentId);
var cities = ByecityCache.Get(key) as List<Letter_City>;
if (cities == null)
{
cities = new List<Letter_City>();
var allCities = AllCities;
for (char i = 'A'; i <= 'Z'; i++)
{
string letter = i.ToString();
var list = from c in allCities
join ct in AllCountries
on c.CountryID equals ct.CountryID
where c.ContinentID == continentId && c.Name_Pinyin_Short.StartsWith(letter, StringComparison.OrdinalIgnoreCase)
orderby c.Hot
select new CountryCityList
{
CityName_CN = c.Name_CN,
CityName_EN = c.Name_EN.ToLower().Replace(SR.Space, SR.UnderLine),
CountryName_EN = ct.Name_EN.ToLower().Replace(SR.Space, SR.UnderLine)
};
if (list.ToList().Count > 0)
{
cities.Add(new Letter_City
{
Letter = letter,
Cities = list.ToList()
});
}
}
ByecityCache.Max(key, cities);
}
return cities;
}