abp(net core)+easyui+efcore实现仓储管理系统目录

abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一)

abp(net core)+easyui+efcore实现仓储管理系统——解决方案介绍(二)

abp(net core)+easyui+efcore实现仓储管理系统——领域层创建实体(三)

abp(net core)+easyui+efcore实现仓储管理系统——定义仓储并实现 (四)

abp(net core)+easyui+efcore实现仓储管理系统——创建应用服务(五)

abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之控制器(六)

abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之列表视图(七)

abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之增删改视图(八)

abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之菜单与测试(九)

abp(net core)+easyui+efcore实现仓储管理系统——多语言(十)

通过abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之控制器(六)abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之菜单与测试(九)四篇文章的学习,我们使用ASP.NET Core Mvc的常规的实现方式实现了对数据库的CURD操作。ABP有其默认的实现增删改查的方式。我们可以先看一下“ABP.TPLMS.Web.Mvc”项目中的“Views\Users”的相关代码,可以查看一下ABP默认是如何实现对用户信息的增删改查的。我们发现ABP中的用户信息的增删改查是通过继承 AsyncCrudAppService这个类来实现CURD操作,前端页面中通过javascript调用WEB API来实现增删改查。当然还有一个同步操作类CrudAppService,通过继承这个类来实现CURD的同步操作。对于这两个类的的区别在于AsyncCrudAppService是CrudAppService异步实现。ABP作为开发框架,通过以上两个基类实现了对于CRUD这种通用功能的一种解决方案。在接下来的几篇文章中,我们要通过继承 AsyncCrudAppService这个类来实现CURD操作,在前端通过调用WebAPI来实现对供应商信息的增删改查功能。

先来看一下AsyncCrudAppService与CrudAppService这两个类具体提供的功能。

首先,这两个类都继承自CrudAppServiceBase类。如图1,图2。

图1

图2

其次,这两个类都提供了Create、Delete、Update、Get、GetAll、GetEntityById方法。

第三,CrudAppServiceBase类提供了有关于权限(xxxPermissionName属性和CheckxxxPermission方法)的属性和方法,关于分页(ApplyPaging)的方法,关于排序(ApplySorting)方法,关于查询条件(CreateFilteredQuery)的方法,关于对象映射(MapToxxx)的方法。如下图。

接下来我们来通过实现一个供应商信息的管理功能来学习一下这种方式实现增删改查功能。我会通过几篇文章来一步一步来实现这个供应商管理的功能。

 一、创建Supplier实体

1. 在Visual Studio 2017的“解决方案资源管理器”中,右键单击“ABP.TPLMS.Core”项目的“Entitys”文件夹,在弹出菜单中选择“添加” --> “类”。 将类命名为 Supplier,然后选择“添加”。

2.创建Supplier类继承自Entity<int>,通过实现审计模块中的IHasCreationTime来实现保存创建时间。代码如下:

using Abp.Domain.Entities;
using Abp.Domain.Entities.Auditing;
using Abp.Timing;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text; namespace ABP.TPLMS.Entitys
{
public class Supplier : Entity<int>, IHasCreationTime
{
public const int MaxLength = ;
public Supplier()
{ this.Address = string.Empty;
this.Name = string.Empty;
this.Email = string.Empty;
this.Code = string.Empty; this.Sex = ;
this.LinkName = string.Empty;
this.Status = ;
this.Tel = string.Empty;
this.Mobile = string.Empty;
this.UserId = ; CreationTime = Clock.Now;
} [Required]
[StringLength()]
public string Code { get; set; } [Required]
[StringLength(MaxLength)]
public string Name { get; set; } [StringLength(MaxLength)]
public string Address { get; set; } [Required]
[StringLength(MaxLength)] public string Email { get; set; } [StringLength(MaxLength)]
public string LinkName { get; set; }
public int Sex { get; set; } [Required]
[StringLength(MaxLength)]
public string Tel { get; set; }
[StringLength(MaxLength)]
public string Mobile { get; set; }
public int Status { get; set; }
public int UserId { get; set; }
public DateTime CreationTime { get; set; }
}
}

3.定义好实体之后,我们去“ABP.TPLMS.EntityFrameworkCore”项目中的“TPLMSDbContext”类中定义实体对应的DbSet,以应用Code First 数据迁移。添加以下代码

using Microsoft.EntityFrameworkCore;
using Abp.Zero.EntityFrameworkCore;
using ABP.TPLMS.Authorization.Roles;
using ABP.TPLMS.Authorization.Users;
using ABP.TPLMS.MultiTenancy;
using ABP.TPLMS.Entitys; namespace ABP.TPLMS.EntityFrameworkCore
{
public class TPLMSDbContext : AbpZeroDbContext<Tenant, Role, User, TPLMSDbContext>
{
/* Define a DbSet for each entity of the application */ public TPLMSDbContext(DbContextOptions<TPLMSDbContext> options)
: base(options) {
} public DbSet<Module> Modules { get; set; }
public DbSet<Supplier> Suppliers { get; set; }
}
}

4.从菜单中选择“工具->NuGet包管理器器—>程序包管理器控制台”菜单。

5. 在PMC中,默认项目选择EntityframeworkCore对应的项目后。输入以下命令:Add-Migration AddEntitySupplier,创建迁移。如下图。

6. 在上面的命令执行完毕之后,创建成功后,会在Migrations文件夹下创建时间_AddEntitySupplier格式的类文件,这些代码是基于DbContext指定的模型。如下图。

7.在程序包管理器控制台,输入Update-Database,回车执行迁移。如下图。

8.执行成功后,查看数据库,Suppliers表创建成功。

abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十一)的更多相关文章

  1. abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十二)

    abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+ ...

  2. abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十三)

    abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+ ...

  3. abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十四)

    abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+ ...

  4. abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十五)

    core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+easyui+e ...

  5. abp(net core)+easyui+efcore实现仓储管理系统——入库管理之五(四十一)

    abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+ ...

  6. abp(net core)+easyui+efcore实现仓储管理系统——出库管理之三(五十一)

    abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统--ABP总体介绍(一) abp(net core)+ ...

  7. abp(net core)+easyui+efcore实现仓储管理系统——菜单 (十六)

    系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+easyui+efcore实现仓储管理系统——解决方案介绍(二) ...

  8. abp(net core)+easyui+efcore实现仓储管理系统——菜单-下(十七)

    实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+easyui+efcore实现仓储管理系统——解决方案 ...

  9. abp(net core)+easyui+efcore实现仓储管理系统——EasyUI前端页面框架 (十八)

    目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+easyui+efcore实现仓储管理系统——解决方案介绍(二) ab ...

随机推荐

  1. centos7PXE和cobbler自动部署装机

    安装程序启动过程MBR:isolinux/boot.catstage2: isolinux/isolinux.bin配置文件:isolinux/isolinux.cfg 每个对应的菜单选项: 加 ...

  2. Liunx 安装 Nessus

    Liunx 安装 Nessus   啥子是Nessus 它是一款系统漏洞扫描与分析软件,可以扫描服务器存在哪些漏洞,页面简介美观,非常Nice. 获取激活码 首先访问如下网站 https://www. ...

  3. 【JDK】ArrayList集合 源码阅读

    这是博主第二次读ArrayList 源码,第一次是在很久之前了,当时读起来有些费劲,记得那时候HashMap的源码还是哈希表+链表的数据结构. 时隔多年,再次阅读起来ArrayList感觉还蛮简单的, ...

  4. hdoj1009 FatMouse' Trade——贪心算法

    贪心思路:按单位猫粮能兑换到的javaBean从大到小将组合进行排序,总是在当前兑换尽可能多的javabeans 问题描述:点击打开链接 hdoj1009 FatMouse's Trade 源代码: ...

  5. K Balanced Teams CodeForces - 1133E (Dp)

    题意: 给出 n 个数,选取其中若干个数分别组成至多 k 组,要求每组内最大值与最小值的差值不超过5,求最后被选上的总人数. 题解: 将a[1∼n] 从小到大排序, f[i][j] 表示到第 i 个数 ...

  6. 解决Spring的java项目打包后执行出现“无法读取方案文档...“、“原因为 1) 无法找到文档; 2) 无法读取文档; 3) 文档的根元素不是...”问题

    问题 一个用Spring建的java项目,在Eclipse或idea中运行正常,为什么打包后运行出现如下错误呢? 2019/07/10/19:04:07 WARN [main] org.springf ...

  7. FluentValidation:一个非常受欢迎的,用于构建强类型验证规则的.NET 库

    1. FluentValidation:一个非常受欢迎的,用于构建强类型验证规则的.NET 库 请求参数实体定义: FluentValidation 验证类定义: 过滤器:ActionFilter中O ...

  8. ajax 前端发含有列表的数据

    在前端页面也可以给后端发送一个包含列表的数据 html <body> <h3>index页面 </h3> <input type="text&quo ...

  9. c++学习书籍推荐《C++沉思录》下载

    百度云及其他网盘下载地址:点我 编辑推荐 经典C++图书,应广大读者的强烈要求再版 目录 第0章 序幕第一篇 动机第1章 为什么我用C++第2章 为什么用C++工作第3章 生活在现实世界中 第二篇 类 ...

  10. webpack-dev-server 小记 原理介绍 概念解读

    使用 DevServer 提供 HTTP 服务而不是使用本地文件预览 监听文件的变化并自动刷新网页,做到实时预览 支持 Source Map,以方便调试 对于这些,Webpack 都为我们考虑好了.W ...