diff --git "a/\351\273\204\345\213\207\350\276\211/Note-2021-6-22.md" "b/\351\273\204\345\213\207\350\276\211/Note-2021-6-22.md" new file mode 100644 index 0000000000000000000000000000000000000000..55eeaf3f94cba78acc8978d74985c894614b6382 --- /dev/null +++ "b/\351\273\204\345\213\207\350\276\211/Note-2021-6-22.md" @@ -0,0 +1,11 @@ +## 今日笔记 + +### dotnet -h (命令) + + 它同时也有支持MVC 的特征,像路由、控制器、action、filter、模型绑定、控制反转(IOC),单元测试 + +5. 它也可以部署在应用程序和IIS上 + +6. 这是一个轻量级的框架,并且对限宽带的设备,支持比较好。 + +7. Response 可以被 Web API 的MediaTypeFormatter 转换成Json、XML或者任何你想转换的格式。 \ No newline at end of file diff --git "a/\351\273\204\345\213\207\350\276\211/Note-2021-6-23.md" "b/\351\273\204\345\213\207\350\276\211/Note-2021-6-23.md" new file mode 100644 index 0000000000000000000000000000000000000000..d126c9164186b2e5f2d83322774753df1eef0a58 --- /dev/null +++ "b/\351\273\204\345\213\207\350\276\211/Note-2021-6-23.md" @@ -0,0 +1,43 @@ +## 今日笔记 + +## 增删改查 + +1. dotnet new sln 建立解决方案文件。 + +2. dotnet new webapi -n 文件夹名称 + +3. dotnet run -p 文件夹名称 -- 运行解决方案 + + +## 二. +. dotnet sln add 文件名称 ---- 将新建项目添加到解决方案中去。 + +5. dotnet build --- 生成.NET项目其所有依赖项 + +6. 查看 .NET 命令代码 dotnet -h + +get/uses 列出所用用户 + +get/users/2 列出指定用户 + +post/users 创建用户 + +put/users/3 修改指定id + +delete/users/4 删除指定id + +### 项目的初始化: + ++ dotnet -h // dotnet 命令 + ++ dotnet new sln // 创建文件夹的解决方案 + ++ dotnet new webapi -n Admin3000.Backend.Api --no-https // 创建文件夹并去掉 https + ++ 退出项目文件 + ++ dotnet run -p 项目文件名称 // 生成并运行项目 + ++ dotnet build // 生成.NET 项目 + ++ dotnet tool install --global dotnet -ef // 安装全局域工具, \ No newline at end of file diff --git "a/\351\273\204\345\213\207\350\276\211/Note-2021-6-26.md" "b/\351\273\204\345\213\207\350\276\211/Note-2021-6-26.md" new file mode 100644 index 0000000000000000000000000000000000000000..f423d533f81a02ab760920ceaad9c0961dd45486 --- /dev/null +++ "b/\351\273\204\345\213\207\350\276\211/Note-2021-6-26.md" @@ -0,0 +1,57 @@ +## 今日笔记 + +1. 使用 .net core cli安装 Ef Core(连接数库使用的包) +``` +// 根据自己使用的数据库选择安装不同的包,可搜索 efCore 查看其他包 +dotnet add package Microsft.EntityFrameworkCore.SqlServer +``` +2. 创建上下文文件 +``` +using Microsoft.EntityFrameworkCore; // 引入ef的包,存在上下文文件类 + +namespace MyApiDemo.api.Data +{ + public class MyApiDemoDb : DbContext + { + // 添加实体 + public DbSet Users { get; set; } + + // 设置配置 options."UseSqlServer" 可以选择各种数据库 + protected override void OnConfiguring(DbContextOptionsBuilder options)=> options.UseSqlServer(@"server=.;database=Demo;uid=sa;pwd=123456"); + } + + + public class Users + { + public Users(){ + CreateTime = DateTime.Now; + UpdateTime = DateTime.Now; + Remarks = ""; + } + public int Id { get; set; } + public string Username { get; set; } + public string Password { get; set; } + public DateTime CreateTime { get; set; } + public DateTime UpdateTime { get; set; } + public string Remarks { get; set; } + } +} +``` +3. 创建数据库 +``` +需要先把一些工具与依赖安装 + +dotnet tool intall --global dotnet-ef // 全局安装EF工具 + +dotnet add package Microsoft.EntityFremaworkCore.Design // 数据迁移时需要用到的依赖包 + +dotnet ef Migrations add 名字 // 添加迁移文件 + +dotnet ef database update // 在数据库中创建表 + +-------------------------------------------------- + +dotnet ef Migrations remove // 删除所有迁移文件 + +dotnet ef database drop // 在数据库中删除表 +``` \ No newline at end of file diff --git "a/\351\273\204\345\213\207\350\276\211/Note-2021-6-29.md" "b/\351\273\204\345\213\207\350\276\211/Note-2021-6-29.md" new file mode 100644 index 0000000000000000000000000000000000000000..acbd122d47a580ce12ec5e63be9af593d2c10c91 --- /dev/null +++ "b/\351\273\204\345\213\207\350\276\211/Note-2021-6-29.md" @@ -0,0 +1,29 @@ +## 今日笔记 + + +## 数据的封装和接口的使用 +1. 定义基类定义的查找对象接口: + +``` + /// + /// 查询数据库,检查是否存在指定ID的对象 + /// + /// 对象的ID值 + /// 存在则返回指定的对象,否则返回Null + [HttpGet] + public virtual T FindByID(string id, string token) + +``` + +2. 增删改查的接口,一般就需要声明式为POST方式来提交,而不是基于安全性的考虑。 + +``` + /// + /// 插入指定对象到数据库中 + /// + /// 指定的对象 + /// 执行操作是否成功。 + [HttpPost] + public virtual CommonResult Insert(T info, string token, string signature, string timestamp, string nonce, string appid) + +``` \ No newline at end of file diff --git "a/\351\273\204\345\213\207\350\276\211/Note-2021-6-30.md" "b/\351\273\204\345\213\207\350\276\211/Note-2021-6-30.md" new file mode 100644 index 0000000000000000000000000000000000000000..8256d8e8af166073405744e2ed8061b17c60bf40 --- /dev/null +++ "b/\351\273\204\345\213\207\350\276\211/Note-2021-6-30.md" @@ -0,0 +1 @@ +## 今日笔记 \ No newline at end of file