コード例 #1
0
ファイル: ProductService.cs プロジェクト: v-dmitruk/EFTask_5
        public Product Get(int ID)
        {
            var mapper = new Mapper(MapperProfile.Configured());

            //IMapper mapper = new MapperConfiguration(x => x.CreateMap<DAL.Product, Product>()).CreateMapper();
            return(mapper.Map <DAL.Product, Product>(_uow.ProductRepository.Get(ID)));
        }
コード例 #2
0
ファイル: ProductService.cs プロジェクト: v-dmitruk/EFTask_5
        public bool AddProduct(Product item)
        {
            //IMapper mapper = new MapperConfiguration(x => x.CreateMap<Product, DAL.Product>()).CreateMapper();
            //IMapper mapper = new MapperConfiguration(x => x.CreateMap<Product, DAL.Product>().
            //ForMember(dest => dest.Categories, opt => opt.MapFrom(src => src.Categories)).
            //ForMember(dest => dest.Provider, opt1 => opt1.MapFrom(y => y.Provider))).
            //CreateMapper();
            var mapper = new Mapper(MapperProfile.Configured());

            _uow.ProductRepository.Create(mapper.Map <Product, DAL.Product>(item));
            return(true);
        }