我很难解决这个问题,如何创建带有界面的视图模型,
我一直在尝试在线遵循一些示例,即
和
http://geekswithblogs.net/michelotti/archive/2009/10/25/asp.net-mvc-view-model-patterns.aspx
但我无法让它工作,任何帮助将不胜感激,我的代码如下。
public class TravelGuideViewModel
{
private readonly IGetCountryDetails _IGCD;
public DisplayCountryDetails displayCountryDetails { get; set; }
public TravelGuideViewModel(IGetCountryDetails IGCD)
{
_IGCD = IGCD;
}
//Trying to get DisplayCountryDetails here, but everything i try does not work
}
======================更新===============
public class TravelGuideViewModel
{
private readonly IGetCountryDetails _IGCD;
public DisplayCountryDetails displayCountryDetails { get; set; }
public TravelGuideViewModel(IGetCountryDetails IGCD)
{
_IGCD = IGCD;
}
public TravelGuideViewModel Asia()
{
var countries = _IGCD.DisplayCountriesOfTheWorldDetails()
.Where(a => a.strCountryContinent == "Asia").FirstOrDefault();
return countries.strCountry.AsEnumerable(); << Does not work
}
}