62,242
社区成员




public List<StateProvince> StateProvinces
{
get
{
return IoC.Resolve<IStateProvinceService>().GetStateProvincesByCountryId(this.CountryId);
}
}
public virtual ICollection<StateProvince> NpStateProvinces { get; set; }
public virtual Country NpCountry { get; set; }
public Country Country
{
get
{
return IoC.Resolve<ICountryService>().GetCountryById(this.CountryId);
}
}
Country country = stateProvince.Country;
public Country GetCountryById(int countryId)
{
if (countryId == 0)
return null;
//如果被缓存的话,就从缓存里面取。
string key = string.Format(COUNTRIES_BY_ID_KEY, countryId);
object obj2 = _cacheManager.Get(key);
if (this.CacheEnabled && (obj2 != null))
{
return (Country)obj2;
}
//如果没有被缓存,就从数据库里面查询。
var query = from c in _context.Countries
where c.CountryId == countryId
select c;
var country = query.SingleOrDefault();
if (this.CacheEnabled)
{
_cacheManager.Add(key, country);
}
return country;
}