Example #1
0
        /// <summary>
        /// Initialize mapper
        /// </summary>
        public void Init()
        {
            MappingExtension.Mapping(Configuration);
            // Static mapper

            Configuration.CreateMap <SupplierModel, SupplierViewModel>().ReverseMap();
            Configuration.CreateMap <CategoryModel, CategoryViewModel>().ReverseMap();
            Configuration.CreateMap <ProductModel, ProductViewModel>()
            .ForMember(d => d.CategoryName, o => o.MapFrom(s => s.Category.Name))
            .ForMember(d => d.SupplierName, o => o.MapFrom(s => s.Supplier.CompanyName))
            .ReverseMap();

            Mapper.Initialize(Configuration);
        }
Example #2
0
        public UserMapConfig()
        {
            ToTable(MappingExtension <User> .GetTableName());

            HasKey(x => x.Id)
            .Property(x => x.Id)
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
            .HasColumnName(MappingExtension <User> .GetTableColumnId());

            Property(e => e.UserName)
            .HasColumnName(MappingExtension <User> .GetTableColumnText(e => e.UserName));
            Property(e => e.Password)
            .HasColumnName(MappingExtension <User> .GetTableColumnText(e => e.Password));
        }