_quatationRepository = new QuatationRepository();
IList<Quatation> quatationObj = _quatationRepository.GetAll(quatation => quatation.IsDeleted == 0);
IList<QuatationModel> quatationModelObj = new List<QuatationModel>();
AutoMapper.Mapper.CreateMap<Quatation, QuatationModel>();
quatationModelObj = AutoMapper.Mapper.Map(quatationObj, quatationModelObj);
return quatationModelObj;
public partial class Quatation
{
public int QuatationId { get; set; }
public int FirmId { get; set; }
public int ItemId { get; set; }
public double Quantity { get; set; }
public decimal Price { get; set; }
public Nullable Dated { get; set; }
public Nullable IsDeleted { get; set; }
public Nullable CreatedDate { get; set; }
public Nullable CreatedBy { get; set; }
public Nullable ModifyDate { get; set; }
public Nullable ModifyBy { get; set; }
public virtual Firm Firm { get; set; }
public virtual Item Item { get; set; }
}
public class QuatationModel
{
public int QuatationId { get; set; }
public int? FirmId { get; set; }
public int ItemId { get; set; }
public double Quantity { get; set; }
public decimal Price { get; set; }
public DateTime? Dated { get; set; }
public int IsDeleted { get; set; }
public DateTime? CreatedDate { get; set; }
public int? CreatedBy { get; set; }
public DateTime? ModifyDate { get; set; }
public int? ModifyBy { get; set; }
//public string ItemName { get; set; }
//public List<SelectListItem> LstFirm { get; set; }
public virtual FirmModel Firm { get; set; }
public virtual ItemModel Item { get; set; }
//public IList<QuatationModel> LstQuatation { get; set; }
}
最佳答案
您必须确保具有相同名称的属性具有相同的类型。例如,一侧的int和另一侧的Nullable将不起作用(IsDeleted)。
关于c# - AutoMapper.dll中发生“AutoMapper.AutoMapperMappingException”,但未在用户代码中处理,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21798506/