[转]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 : 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

时间: 2024-08-02 02:51:26

[转]How to add new table in NopCommerce的相关文章

Inheritance with EF Code First: Part 2 – Table per Type (TPT)

In the previous blog post you saw that there are three different approaches to representing an inheritance hierarchy and I explained Table per Hierarchy (TPH) as the default mapping strategy in EF Code First. We argued that the disadvantages of TPH m

asp.net实现动态添加table行

asp.net动态的生成,删除table的行,主要是在后台动态创建单元行,单元表格,效果图: 2.代码: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="releaseAffair.aspx.cs" Inherits="affair_releaseAffair" %> <!DOCTYPE html> <!--发布事务页面:名称Affa

动态添加table表格内容,填充审批意见。

一,前台 <asp:table id="tblApprove" runat="server" Width="100%"></asp:table> 二.后台 QueryApproveInfo private void SetTable() { TableRow tblRow = new TableRow(); TableCell tblCell = new TableCell(); tblCell.Text = "

HashSet集合的add()方法的源码

interface Collection { ... } interface Set extends Collection { ... } class HashSet implements Set { private static final Object PRESENT = new Object(); private transient HashMap<E,Object> map; public HashSet() { map = new HashMap<>(); } publi

table标签里插入form标签的奇怪现象

最近帮朋友处理它的表单无法提交的问题,弄了些时间,发现了一个奇怪的问题 <table> <form action="upload.php" method="post" enctype="multipart/form-data"> <input type="text" name="t" /> <input type="submit" value=&

Table &#39;mxonline.xadmin_log&#39; doesn&#39;t exist

使用xadmin源码安装出现报错: ProgrammingError at /xadmin/users/emailverifyrecord/add/(1146, "Table 'mxonline.xadmin_log' doesn't exist") 解决: 原因是缺少了一些表.在manage.py Task中 makemigrations 和 migrate 即可解决 Table 'mxonline.xadmin_log' doesn't exist 原文地址:https://www

转换sql文件的create table语句为drop table语句

1 package com.csii.pweb.query.action; 2 3 import java.io.BufferedReader; 4 import java.io.FileNotFoundException; 5 import java.io.FileReader; 6 import java.io.IOException; 7 import java.util.ArrayList; 8 import java.util.List; 9 10 11 public class Ja

【2016-11-2】【坚持学习】【Day17】【微软 推出的SQLHelper】

从网络上找到 微软原版本的SQLHelper,很多行代码.认真看了,学习了. 代码: 1 using System; 2 using System.Data; 3 using System.Xml; 4 using System.Data.SqlClient; 5 using System.Collections; 6 7 namespace Helper 8 { 9 /// <summary> 10 /// The SqlHelper class is intended to encapsu

任意进制转换算法

任意进制转换算法 N年没有写博客,发个进制转换的玩下,支持负数:功能属于简化版的 Convert.ToInt32 ,特点是: 1.任意位,如:0,1(二进制),0...7(八进制),0...9,A...F(16进制),0...N(N进制),或者是:[email protected]#$%^&*(8进制,字符符号),也可以是中文. 2.8 byte 最大长度. 3.C#源码. 最近写markdown格式习惯啦,cnblogs啥时候全改掉算了,别用这个htmleditor算了. 先说明下进制转换的基