Getting an exception with AutoMapper

前端 未结 2 1573
孤独总比滥情好
孤独总比滥情好 2021-01-04 03:48

I\'m unit testing a method which uses automapper to map a class from my domain to a linq to sql class. Roughly, the classes and mapping are below (The SupplierEligibilityAl

相关标签:
2条回答
  • 2021-01-04 04:25

    It appears you are specifying the wrong type on your call to Mapper.CreateMap

    Try doing something like the following:

    Mapper.CreateMap<SupplierEligibilityTransactionByQuantity, SupplierEligibilityAllocated>()
    
    0 讨论(0)
  • 2021-01-04 04:28

    If any one using Mapper.Map() check your mapping class & table/store procedure properly.

    public static CustomerLedgerViewModel ToModel(this DJBL_tblCustomerCurrentLedger obj)
    {
        return Mapper.Map<DJBL_tblCustomerCurrentLedger, CustomerLedgerViewModel>(obj);
    }
    
    public static DJBL_tblCustomerCurrentLedger ToEntity(this CustomerLedgerViewModel model)
    {
        return Mapper.Map<CustomerLedgerViewModel, DJBL_tblCustomerCurrentLedger>(model);
    } 
    
    0 讨论(0)
提交回复
热议问题