[轉]How to add new table in NopCommerce

來源:互聯網
上載者:User

標籤:bsp   pat   for   comm   com   exp   ber   pre   app   

本文轉自: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 : Solution\Libraries\Nop.Core\Domain\Entity.cs


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

Path : Solution\Libraries\Nop.Data\Mapping\EntityMap.cs


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

Path : Solution\Presentation\Nop.Web\Models\EntityModel.cs (for Web)      

Path : Solution\Presentation\Nop.Admin\Models\EntityModel.cs (for Admin)


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

Path : Solution\Presentation\Nop.Web\Validators\EntityValidator.cs (for Web)      

Path : Solution\Presentation\Nop.Admin\Validators\EntityValidator.cs (for Admin)


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

Path : Solution\Presentation\Nop.Admin\Infrastructure
       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 : Solution\Presentation\Nop.Web\Extensions\(for Web)      

Path : Solution\Presentation\Nop.Admin\Extensions\(for Admin)


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

Path : Solution\Libraries\Nop.Services\IEntityService.cs      

Path : Solution\Libraries\Nop.Services\EntityService.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

 

[轉]How to add new table in NopCommerce

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.