ile bir istisna alma Birimi, bir alanımı bir linq'den sql sınıfına eşlemek için automapper kullanan bir yöntemi test ediyorum. Kabaca, sınıflar ve haritalama aşağıdadır (SupplierEligibilityAllocated, bir L2S otomatik oluşturulan sınıftır).AutoMapper
public class SupplierEligibilityTransactionByQuantity
{
public decimal Eligibility { get; private set; }
public decimal CoreValue { get; private set; }
public int? TransactionId { get; private set; }
public SupplierTransactionStatus Status { get; private set; }
public int? DebitId { get; set; }
public int ManifestId { get; private set; }
}
public partial class SupplierEligibilityAllocated
{
private int _SupplierEligibilityCreditId;
private int _ManifestId;
private System.Nullable<int> _QuantityApplied;
private System.Nullable<decimal> _AmountApplied;
private System.Nullable<decimal> _CoresReservedByAmount;
private System.DateTime _InsertDate;
private EntityRef<Manifest> _Manifest;
private EntityRef<SupplierEligibilityCredit> _SupplierEligibilityCredit;
}
private static void Map_SupplierEligibilityTransactionByQuantity_To_SupplierEligibilityAllocated()
{
Mapper.CreateMap<EligibilityTransactionByQuantity, SupplierEligibilityAllocated>()
.ForMember(dest => dest.SupplierEligibilityCreditId, opt => opt.MapFrom(src => src.TransactionId))
.ForMember(dest => dest.ManifestId, opt => opt.MapFrom(src => src.ManifestId))
.ForMember(dest => dest.QuantityApplied, opt => opt.MapFrom(src => Convert.ToInt32(src.Eligibility)))
.ForMember(dest => dest.AmountApplied, opt => opt.Ignore())
.ForMember(dest => dest.CoresReservedByAmount, opt => opt.Ignore())
.ForMember(dest => dest.InsertDate, opt => opt.MapFrom(src => DateTime.UtcNow))
.ForMember(dest => dest.Manifest, opt => opt.Ignore())
.ForMember(dest => dest.SupplierEligibilityCredit, opt => opt.Ignore());
}
Yöntem, eşleştirmeyi yürüttüğünde, aşağıdaki istisnayı atar.
Trying to map SupplierEligibilityTransactionByQuantity to SupplierEligibilityAllocated.
Missing type map configuration or unsupported mapping.
Exception of type 'AutoMapper.AutoMapperMappingException' was thrown.
at AutoMapper.MappingEngine.AutoMapper.IMappingEngineRunner.Map(ResolutionContext context)
at AutoMapper.MappingEngine.Map(Object source, Type sourceType, Type destinationType)
at AutoMapper.MappingEngine.Map[TSource,TDestination](TSource source)
at AutoMapper.Mapper.Map[TSource,TDestination](TSource source)
Ben Testten önce eşleme oluşturma doğruladıktan ve herhangi bir sorun olmadan
Mapper.AssertConfigurationIsValid()
aradı. Eşleştirmeyi de sorunsuz bir şekilde yaptım. Buna neyin sebep olacağı konusunda bir fikri olan var mı?
Mapper.Map()
kullanarak herhangi bir harita oluşturma sınıfı & tablo/mağaza prosedürünü düzgün işaretlerseniz
Mapper.CreateMap<SupplierEligibilityTransactionByQuantity, SupplierEligibilityAllocated>()
any1 için orada u IgnoreDataMember attr koymak olasılığı her zaman olduğunu ve ur sınıfının dışında u göremiyorum anlamına gelir, bu benim sorunum bu eski – bresleveloper