Exemple #1
0
        private void ConfigureMappers(IMapperConfigurationExpression cfg)
        {
            cfg.AddCollectionMappers();

            // From Dto to Entity
            cfg.CreateMap <NamedInsuredDto, NamedInsured>();
            cfg.CreateMap <ApplicationDto, Application>();

            // From Entity to Dto
            cfg.CreateMap <State, StateDto>().EqualityComparison((s, sdto) => s.Abbreviation == sdto.Abbreviation);
            cfg.CreateMap <Coverage, CoverageDto>().EqualityComparison((c, cdto) => c.Id == cdto.Id);
            cfg.CreateMap <StateCoverage, StateCoverageDto>()
            .EqualityComparison((sc, scdto) => sc.Id == scdto.Id);
            //.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
            //.ForMember(dest => dest., opt => opt.MapFrom(src => src.CoverageId))

            /*
             * .ForMember(dest => dest.StateAbbreviation, opt => opt.MapFrom(src => src.StateAbbreviation))
             * .ForMember(dest => dest.CoverageName, opt => opt.MapFrom(src => src.Coverage.Name))
             * .ForMember(dest => dest.PerPersonLimit, opt => opt.MapFrom(src => src.PerPersonLimit))
             * .ForMember(dest => dest.PerAccidentLimit, opt => opt.MapFrom(src => src.PerAccidentLimit))
             * .ForMember(dest => dest.Deductible, opt => opt.MapFrom(src => src.Deductible))
             * .ForMember(dest => dest.IsRequired, opt => opt.MapFrom(src => src.IsRequired));
             */
        }
Exemple #2
0
            protected override void Create(IMapperConfigurationExpression cfg)
            {
                cfg.ShouldMapProperty = propertyInfo => propertyInfo.GetMethod.IsPublic || propertyInfo.GetMethod.IsAssembly || propertyInfo.GetMethod.IsFamily || propertyInfo.GetMethod.IsPrivate;
                cfg.AddCollectionMappers();

                //DOMAIN --> EF
                cfg.CreateMap <RootDomain, RootEf>()
                .ForMember(rootEf => rootEf.Orders, opt => opt.MapFrom <MergeDomainOrdersToEfOrdersValueResolver>())
                ;

                //collection type
                cfg.CreateMap <OrderDomain, OrderEf>()
                .EqualityComparison((oo, dto) => BaseEquals(oo, dto))
                ;

                cfg.CreateMap <OnlineOrderDomain, OnlineOrderEf>()
                .EqualityComparison((ood, ooe) => DerivedEquals(ood, ooe))
                .IncludeBase <OrderDomain, OrderEf>()
                ;

                cfg.CreateMap <MailOrderDomain, MailOrderEf>()
                .IncludeBase <OrderDomain, OrderEf>()
                ;

                //EF --> DOMAIN
                cfg.CreateMap <RootEf, RootDomain>()
                .ForMember(rootDomain => rootDomain.OnlineOrders, opt => opt.MapFrom(rootEf => rootEf.Orders.Where(orderEf => orderEf.GetType() == typeof(OnlineOrderEf))))
                .ForMember(rootDomain => rootDomain.MailOrders, opt => opt.MapFrom(rootEf => rootEf.Orders.Where(orderEf => orderEf.GetType() == typeof(MailOrderEf))))
                ;

                cfg.CreateMap <OrderEf, OrderDomain>()
                ;

                cfg.CreateMap <OnlineOrderEf, OnlineOrderDomain>()
                .IncludeBase <OrderEf, OrderDomain>()
                ;

                cfg.CreateMap <MailOrderEf, MailOrderDomain>()
                .IncludeBase <OrderEf, OrderDomain>()
                ;
            }
 protected virtual void ConfigureMapper(IMapperConfigurationExpression cfg)
 {
     cfg.AddCollectionMappers();
     cfg.CreateMap <ThingDto, Thing>().EqualityComparison((dto, entity) => dto.ID == entity.ID);
 }
 private void ConfigureMapper(IMapperConfigurationExpression cfg)
 {
     cfg.AddCollectionMappers();
     cfg.CreateMap <ThingDto, Thing>().ReverseMap();
     cfg.SetGeneratePropertyMaps <GenerateEntityFrameworkPrimaryKeyPropertyMaps <DB> >();
 }