-1
我正在使用AutoMapper来映射两个对象。 ViewModel和Model,其中ViewModel实现InotifyPropertyChanged。我如何将模型映射到ViewModel。下面是我的方案,Automapper映射异常与模型和私有属性
型号
公共类型号 { 公共字符串与resultType {获得;组; }}
视图模型
公共类视图模型:屏幕 { 私人字符串_resultType;
public string ResultType { get { return _resultType; } set { _resultType = value; NotifyOfPropertyChange(() => ResultType); } }
}
创建地图实现
mapper.CreateMap(); mapper.CreateMap(); mapper.AssertConfigurationIsValid();
var test1 = new Model() {ResultType = "Test Result"}; var s1 = mapper.Map<ViewModel>(test1);
我得到AutoMapper映射的异常当我打电话mapper.Map。
缺少类型映射配置或不支持的映射。 映射类型: 型号 - >视图模型 Support.Model - > Support.ViewModel
请出示您的映射。 – Rabban