zoukankan      html  css  js  c++  java
  • [转]How to add new table in NopCommerce

    本文转自:http://www.tech-coder.com/2015/07/how-to-add-new-table-in-nopcommerce.html

    Hey guys I am back after a long time near about 2 year. And hope my previous blogs help's to anyway to my friends.
    So I am going to starting with NopCommerce for how to add new table. This is the common question for newbie of NopCommerce.
    Basically here sharing my experience with you guys that will help to other.
    Step by step explanation for how to add new table on NopCommerce.
    Going to explain based on the NopCommerce source code.  

    So first open source code on visual studio then follow the below steps (Also refer any existing classes/table).
    1. Create the Entity class related to table name (e.g. Enity.cs)      

    Path : SolutionLibrariesNop.CoreDomainEntity.cs


    2. Create a Mapping class which bind class to Database table (e.g. EntityMap.cs)      

    Path : SolutionLibrariesNop.DataMappingEntityMap.cs


    3. Create a Model class for MVC (i.e. for Admin or Web) (e.g EntityModel.cs)      

    Path : SolutionPresentationNop.WebModelsEntityModel.cs (for Web)      

    Path : SolutionPresentationNop.AdminModelsEntityModel.cs (for Admin)


    4. Create a validator for model (e.g. EntityValidator.cs)      

    Path : SolutionPresentationNop.WebValidatorsEntityValidator.cs (for Web)      

    Path : SolutionPresentationNop.AdminValidatorsEntityValidator.cs (for Admin)


    5. Create A Mapping Configuration On AutoMapperStartupTask.cs for Entity and Model      

    Path : SolutionPresentationNop.AdminInfrastructure
           Mapping Model to Entity and Entity to Model

            Mapper.CreateMap<MyTest, MyTestModel>()
            .ForMember(dest => dest.Name, mo => mo.Ignore())
            .ForMember(dest => dest.MyTestId, mo => mo.Ignore());
     
            Mapper.CreateMap<MyTestModel, MyTest>()
            .ForMember(dest => dest.Name, mo => mo.Ignore())
            .ForMember(dest => dest.MyTestId, mo => mo.Ignore());
    
    
    
    

    6. Apply Mapping between Model and Entity on MappingExtensions.cs      

    Path : SolutionPresentationNop.WebExtensions(for Web)      

    Path : SolutionPresentationNop.AdminExtensions(for Admin)


    7. Create a service class and service interface (e.g EntityService.cs , IEntityService.cs)      

    Path : SolutionLibrariesNop.ServicesIEntityService.cs      

    Path : SolutionLibrariesNop.ServicesEntityService.cs


    8. Final step to create Controller and View for given Model.
    Hope you get basic idea how to create/add new table on NopCommerce system

  • 相关阅读:
    Win7系统中打开exe 无反应
    IE 浏览器主页劫持 如何修复
    win10 airpods显示已配对,但就是连不上怎么办?
    tp5 layui 渲染 时间戳转换为日期时间格式
    为什么要设置 繁琐的密码
    美食摄影 – 明确目的
    MsMpEng.exe进程停止删除或弹出设备,导致移动硬盘无法正常弹出,怎么办?
    单抗热门靶点 | VEGF | TNF-α | CD20 | HER2 | PD-1 | IL-6R | CD47
    EZH2 | Ezh2 | 组蛋白甲基化酶/组蛋白甲基转移酶
    宇宙微波背景辐射 | 著名实验
  • 原文地址:https://www.cnblogs.com/freeliver54/p/6170989.html
Copyright © 2011-2022 走看看