From 3f2b20d50a0bb27774a18d5d6dd22b6a318279dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E9=9B=A8=E8=89=AF?= <14091846+xiaobayei@user.noreply.gitee.com> Date: Sun, 29 Dec 2024 13:13:13 +0000 Subject: [PATCH] =?UTF-8?q?=E7=AC=94=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 郑雨良 <> --- ...05\345\255\246\347\224\237\350\241\250.md" | 47 +++++++++++++++++++ ...5\347\237\245\350\257\206\347\202\2712.md" | 14 ++++++ .../20241226-\347\254\224\350\256\260.md" | 1 + 3 files changed, 62 insertions(+) create mode 100644 "\351\203\221\351\233\250\350\211\257/\347\254\224\350\256\260\344\275\234\344\270\232/20241223-\347\237\245\350\257\206\350\241\245\345\205\205\345\255\246\347\224\237\350\241\250.md" create mode 100644 "\351\203\221\351\233\250\350\211\257/\347\254\224\350\256\260\344\275\234\344\270\232/20241225-\350\241\245\345\205\205\347\237\245\350\257\206\347\202\2712.md" create mode 100644 "\351\203\221\351\233\250\350\211\257/\347\254\224\350\256\260\344\275\234\344\270\232/20241226-\347\254\224\350\256\260.md" diff --git "a/\351\203\221\351\233\250\350\211\257/\347\254\224\350\256\260\344\275\234\344\270\232/20241223-\347\237\245\350\257\206\350\241\245\345\205\205\345\255\246\347\224\237\350\241\250.md" "b/\351\203\221\351\233\250\350\211\257/\347\254\224\350\256\260\344\275\234\344\270\232/20241223-\347\237\245\350\257\206\350\241\245\345\205\205\345\255\246\347\224\237\350\241\250.md" new file mode 100644 index 0000000..7844163 --- /dev/null +++ "b/\351\203\221\351\233\250\350\211\257/\347\254\224\350\256\260\344\275\234\344\270\232/20241223-\347\237\245\350\257\206\350\241\245\345\205\205\345\255\246\347\224\237\350\241\250.md" @@ -0,0 +1,47 @@ +# 笔记 + +1. IEnumerable -->可迭代;可遍历;(集合接口) +**用了就可以用foreach** +例:`@model IRnumerable` + +2. 视图中要引用数据库的内容 + 2.1 写: + ```c# + public class StudentsController : Controller + { + //ScoreDbContext 是类数据库的那个伪库 + //_db是自己取得名字用来代替数据库名字 + private readonly ScoreDbContext _db; + //构造函数 + //名字要和控制器名字一模一样 + public StudentDbContext() + { + _db = new ScoreDbContext (); + } + //下一步:Index中要返回视图中 + //Index中的return View(_db.Courses)--->Courses和ScorewDbContext中Dbset取得名字一样 + + } + ``` + +3. `405的错误是`: ++ 参数错误 ++ Method对不上 + + +4. `404错误是:`**找不到页面** ++ 若无书写上的错误就重跑 + +5. 505请求处了问题 + +6. **编辑是Update 不是Add** +例:新增 +```c# +[HttpPost] +public IActionResult Create(Course input){ + //这里是Add;编辑就是Update + _db.Courses.Add(input); + _db.SaveChanges(); + return RedirectToAction("Index") +} +``` diff --git "a/\351\203\221\351\233\250\350\211\257/\347\254\224\350\256\260\344\275\234\344\270\232/20241225-\350\241\245\345\205\205\347\237\245\350\257\206\347\202\2712.md" "b/\351\203\221\351\233\250\350\211\257/\347\254\224\350\256\260\344\275\234\344\270\232/20241225-\350\241\245\345\205\205\347\237\245\350\257\206\347\202\2712.md" new file mode 100644 index 0000000..73f5bad --- /dev/null +++ "b/\351\203\221\351\233\250\350\211\257/\347\254\224\350\256\260\344\275\234\344\270\232/20241225-\350\241\245\345\205\205\347\237\245\350\257\206\347\202\2712.md" @@ -0,0 +1,14 @@ +## 笔记 + +1. 查询功能 method用的**get** + +2. from中写name=abc 这里的abc相当于keyword ++ 之后的Index中要(string abc)拿到参数 ++ 返回可以用:`return JsonSerializar.Serialize new{abc}` + +3. [ FromQuery] =>查询字符串 + +4. + 前|| 后 :如前对,后不执行 + + 前|后 : 都判断一遍 + + diff --git "a/\351\203\221\351\233\250\350\211\257/\347\254\224\350\256\260\344\275\234\344\270\232/20241226-\347\254\224\350\256\260.md" "b/\351\203\221\351\233\250\350\211\257/\347\254\224\350\256\260\344\275\234\344\270\232/20241226-\347\254\224\350\256\260.md" new file mode 100644 index 0000000..ab76a70 --- /dev/null +++ "b/\351\203\221\351\233\250\350\211\257/\347\254\224\350\256\260\344\275\234\344\270\232/20241226-\347\254\224\350\256\260.md" @@ -0,0 +1 @@ +# 综上所述的完成完整过程 \ No newline at end of file -- Gitee