// 嗨,大家好
我在做这个行动电话:
[HttpGet]
public virtual ActionResult JsonGetProvinces(int countryId)
{
//WebSiteContext WbContext = new WebSiteContext();
//UnitOfWork UnitofWork = new UnitOfWork(WbContext);
var provinces =
(
from province in unitofWork.ProvinceRepository.All
where province.CountryId == countryId
select new
{
Id = province.Id,
Name = province.GetType().GetProperty("Name_" + CultureManager.GetCurrentCultureShortName()).GetValue(province)
}
).ToList();
return Json(provinces, JsonRequestBehavior.AllowGet);
}
什么是错我的查询:
var provinces =
(
from province in unitofWork.ProvinceRepository.All
where province.CountryId == countryId
select new
{
Id = province.Id,
Name = province.GetType().GetProperty("Name_" + CultureManager.GetCurrentCultureShortName()).GetValue(province)
}
).ToList();
格外, 名称= province.GetType()的getProperty( “名_” + CultureManager.GetCurrentCultureShortName())。的GetValue(省)
在BDD,有Name_fr
, Name_en
列,我试图采取一个动态......这可能吗?
当然,我可以把两者并动态地选择在视图中的列,但我会知道怎么做...
谢谢您的帮助