abp(net core)+easyui+efcore实现仓储管理系统目录
<https://www.cnblogs.com/chillsrc/p/11231284.html>

abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一)
<https://www.cnblogs.com/chillsrc/p/10913047.html>

abp(net core)+easyui+efcore实现仓储管理系统——解决方案介绍(二)
<https://www.cnblogs.com/chillsrc/p/10944870.html>

abp(net core)+easyui+efcore实现仓储管理系统——领域层创建实体(三)
<https://www.cnblogs.com/chillsrc/p/10980974.html>

 abp(net core)+easyui+efcore实现仓储管理系统——定义仓储并实现 (四)
<https://www.cnblogs.com/chillsrc/p/11024357.html>

abp(net core)+easyui+efcore实现仓储管理系统——创建应用服务(五)
<https://www.cnblogs.com/chillsrc/p/11065667.html>

abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之控制器(六)
<https://www.cnblogs.com/chillsrc/p/11096690.html>

abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之列表视图(七)
<https://www.cnblogs.com/chillsrc/p/11124614.html>

abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之增删改视图(八)
<https://www.cnblogs.com/chillsrc/p/11159642.html>

abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之菜单与测试(九)
<https://www.cnblogs.com/chillsrc/p/11195189.html>

abp(net core)+easyui+efcore实现仓储管理系统——多语言(十)
<https://www.cnblogs.com/chillsrc/p/11231265.html>

 

      通过abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之控制器(六)
<https://www.cnblogs.com/chillsrc/p/11096690.html>至abp(net
core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之菜单与测试(九)
<https://www.cnblogs.com/chillsrc/p/11195189.html>四篇文章的学习,我们使用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 = 255; public Supplier() { this.Address = string
.Empty;this.Name = string.Empty; this.Email = string.Empty; this.Code = string
.Empty;this.Sex = 0; this.LinkName = string.Empty; this.Status = 0; this.Tel =
string.Empty; this.Mobile = string.Empty; this.UserId = 0; CreationTime =
Clock.Now; } [Required] [StringLength(50)] 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表创建成功。



 

 

友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:637538335
关注微信