asp.net core -.net3.1
ABP .net core 3.1x
.net 跟 .net core
.NET 是一个开发平台,或者叫开发者平台
什么是.NET?什么是.NET Core?.NET和.NET Core区别又是什么呢?
C# Abp
ABP是“ASP.NET Boilerplate Project (ASP.NET样板项目)”的简称。
ABP vNext 的前身是 asp.net boilerplate(老版 abp)
ABP(ASP.NET Boilerplate Project)快速入门 比较有用
LINQ (Language Integrated Query)
1、什么是Linq?
LINQ是一组语言特性和API,可以使用统一的方式编写各种查询。用于保存和检索来自不同数据源的数据,从而消除了编程语音和数据库之间的不匹配,以及为不同类型的数据源提供单个查询接口。
2、LINQ主要包含三个部分:
环境搭建
前端:
pnpm Install
pnpm serve
pnpm build
后端:
add-migration mytest1
update-database
"Default":"Server=;Database=DB;uid=sa;pwd=122223;MultipleActiveResultSets=true;"
"Default": "Server=.; Database=DB;uid=sa;pwd=123456;MultipleActiveResultSets=true;"
数据迁移指令
add-migration name
新增实体并映射
using Abp.Domain.Entities;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace EIIT.MES.Infrastructure
{
[Serializable]
//[Table("BaseSupplier")]
public class BaseSupplier : EntityBase
{
[Required]
[MaxLength(64)]
public string SupCode { get; set; }
[Required]
[MaxLength(64)]
public string SupName { get; set; }
}
}
生态
问题1 环境配置、迁移失败、前端运行
前端:nodejs 版本过高
"scripts": {
"serve": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve",
"build": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build"
},
Both Entity Framework Core and Entity Framework 6 are installed. The Entity Framework Core tools are running. Use 'EntityFramework6\Add-Migration' for Entity Framework 6.
Build started...
Build succeeded.
You must install or update .NET to run this application.
App: C:\Users\Administrator\.nuget\packages\microsoft.entityframeworkcore.tools\3.1.4\tools\netcoreapp2.0\any\ef.dll
Architecture: x64
Framework: 'Microsoft.AspNetCore.App', version '3.1.0' (x64)
.NET location: C:\Program Files\dotnet\
The following frameworks were found:
6.0.16 at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
7.0.5 at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Learn about framework resolution:
https://aka.ms/dotnet/app-launch-failed
To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=3.1.0&arch=x64&rid=win10-x64
下载https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=3.1.0&arch=x64&rid=win10-x64
因为.net 是3.1 2022没有这个
数据迁移
1、添加供应商到里面,实现首次迁移
迁移日志:20220906004551_first_migration.cs
2、操作方法
按正常流程建类,迁移,把迁移日志的Down Up里面内容放到 20220906004551_first_migration.cs
3、down:protected override void Up(MigrationBuilder migrationBuilder
up:protected override void Down(MigrationBuilder migrationBuilder
前端
创建DTO
System.ComponentModel.DataAnnotations验证字段数据正确性
using System.ComponentModel.DataAnnotations;
public class BaseListDto : EntityBaseDto
{
/// <summary>
/// FactoryCode
/// </summary>
[Required(ErrorMessage = "FactoryCode不能为空")]
public string FactoryCode { get; set; }
/// <summary>
/// FactoryName
/// </summary>
[Required(ErrorMessage = "FactoryName不能为空")]
public string FactoryName { get; set; }
}
创建接口
两个文件:BaseSupplierAppService 、IBaseSupplierAppService
| BaseSupplier.cs
│ BaseSupplierAppService.cs
│ IBaseSupplierAppService.cs
│
└─Dtos
BaseSupplierListDto.cs
1、文件建立
- BaseSupplierAppService:
using Abp.Authorization;
using System;
using System.Collections.Generic;
using System.Text;
namespace EIIT.MES.Infrastructure
{
/// <summary>
/// 应用层服务的接口实现方法
///</summary>
//[AbpAuthorize]
public class BaseSupplierAppService : MESAppServiceBase, IBaseSupplierAppService
{
}
}
- IBaseSupplierAppService
namespace EIIT.MES.Infrastructure
{
/// <summary>
/// 应用层服务的接口实现方法
///</summary>
//[AbpAuthorize]
public class BaseSupplierAppService : MESAppServiceBase, IBaseSupplierAppService
{
}
}
2、BaseSupplierAppService 添加
private readonly IRepository<BaseSupplier, long> _baseSupplierRepository;
/// <summary>
/// 构造函数
///</summary>
public BaseSupplierAppService(IRepository<BaseSupplier, long> baseSupplierRepository)
{
_baseSupplierRepository = baseSupplierRepository;
}
本文作者:六月开发者博客主页
本文链接:https://www.cnblogs.com/juneaba/p/17264988.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步