1.三张表的关系
2.接口的实现
public byte[] SCCToXlsx(IEnumerable<County> StateProvinceCC) { var properties = new[] { new PropertyByName<County>("区/县", p => p.Name), new PropertyByName<County>("城市", p =>GetCity(p.CityId)), new PropertyByName<County>("省份", p =>GetStateProvinceName(GetStateProvince(p.CityId))) }; return ExportToXlsx(properties, StateProvinceCC); } //通过区县id获取城市名称 public string GetCity(int id) { return _cityService.GetCityById(id).Name; } /// <summary> /// 得到省的id /// </summary> /// <param name="id"></param> /// <returns></returns> public int GetStateProvince(int id) { return _cityService.GetCityById(id).StateProvinceId;//省的id } /// <summary> /// 通过id获取到省名称 /// </summary> /// <param name="id"></param> /// <returns></returns> public string GetStateProvinceName(int id) { return _stateProvinceService.GetStateProvinceById(id).Name; ; }