当前位置: 首页 > news >正文

江苏营销型网站公司网络平台管理制度

江苏营销型网站公司,网络平台管理制度,网站系统改教程,济宁百度竞价推广Linq集成查询#xff08;关联Lambda#xff09; First FirstOrDefault 找到第一个符合条件的元素 First(x x.Id id) 返回第一个Id等于id的元素#xff0c;如果都没有符合的#xff0c;报错FirstOrDefault(x x.Id id) 返回第一个Id等于id的元素#xff0c;如果…Linq集成查询关联Lambda First FirstOrDefault 找到第一个符合条件的元素 First(x x.Id id) 返回第一个Id等于id的元素如果都没有符合的报错FirstOrDefault(x x.Id id) 返回第一个Id等于id的元素如果都没有符合的返回Null Single SingleOrDefault Single() 返回第一个Id等于id的元素如果都没有符合的报错SingleOrDefault() 返回第一个Id等于id的元素如果都没有符合的返回Null Where Where(xx.Score80 x.Sex1) 查找所有成绩大于等于80并且性别为1的所有元素 4.SelectSelect(xnew{x.Id,x.Score}) 以新的{x.Id,x.Score}对象形式返回新的集合 如何将增删改查的增改添加数据传输到页面 1. 在新增页面Increase.cshtml中修改为 model Blog.Models.Blogs; h2新增/h2 form asp-ControllerBlogs asp-actionIncrease methodpostlabel标题input asp-forTitle//label br/label内容input asp-forContent//label br/label作者input asp-forAuthor//label br/button typesubmit保存/button /form2. 在BlogsController.cs中添加 [HttpPost]public Blogs Increase(Blogs input){return input;}-就可以添加新增到页面。但需要验证数据库是否成功成功跳转到列表页吗验证不通过仍显示新增页面并显示 所以单单这样验证是不通过的并且显示 {id: 0,title: 你好,content: 星期三,author: 哈哈 }完整版 需要配合上一篇mvc的增删改查一起 BlogsController.cs using Microsoft.AspNetCore.Mvc; using Blog.Models; namespace Blog.Controllers;public class BlogsController : Controller {public IActionResult Index(){return View(Db.Blogs);}/// summary/// 创建-展示新增页面/// /summary/// returns/returns public IActionResult Increase(){return View();}/// summary/// 创建-保存表单结果的Action/// /summary/// param nameinput/param/// returns/returns[HttpPost]public IActionResult Increase(Blogs input){// return input;// 1.验证表单数据是否可以传入// 2.拿到传入的数据后一般做验证数据验证如必填手机号长度名称是否唯一// 3.如果符合验证规则则保存到数据库否则提示验证不通过// 4.如果保存数据库成功则跳转列表页如果验证不成功那就仍然显示新增页面// var maxIdDb.Blogs.First();// var maxIdDb.Blogs.FirstOrDefault();// var maxIdDb.Blogs.Single(xx.Id0);// var maxIdDb.Blogs.SingleOrDefault(xx.Id0);// double.Blogs.Add(inout)// 先通过select 拿到集合中的所有id放在一个新的集合中返回然后对这个返回的新的集合应用Max方法找到其中最大值 // var blogs Db.Blogs.Where(x x.Title.Equals(input.Title));// if (blogs.Count() 0)// {// return View(create);// }var maxIdDb.Blogs.Select(x x.Id).Max();input.IdmaxId 1;Db.Blogs.Add(input);return RedirectToAction(Index);}// 新// 获得Idpublic IActionResult Redact(int id){// 根据id找到对应的blogs有可能为空var blog Db.Blogs.FirstOrDefault(x x.Id id);return View(blog);}// 新[HttpPost]public IActionResult Redact(Blogs input){// 根据id找到对应的blogs有可能为空var blog Db.Blogs.FirstOrDefault(x x.Id input.Id);if (blog ! null){blog.Title input.Title;blog.Content input.Content;blog.Author input.Author;}return RedirectToAction(Index);}public IActionResult Delete(){return View();} }Index.cshtml页面 link relstylesheet href~/css/base.css model ListBlog.Models.Blogsa asp-actionIncrease增加/a tabletrthId/thth标题/thth内容/thth作者/thth操作/th/trforeach(var item in Model){trtditem.Id/tdtditem.Title/tdtditem.Content/tdtditem.Author/tdtda asp-actionRedact asp-route-iditem.Id编辑/aa asp-actionDelete asp-rout-iditem.Id删除/a/td/tr} /tableIncrease.cshtml页面 model Blog.Models.Blogs; h2新增/h2 form asp-ControllerBlogs asp-actionIncrease methodpostlabel标题input asp-forTitle//label br/label内容input asp-forContent//label br/label作者input asp-forAuthor//label br/button typesubmit保存/button /form*注释部分 tableform actiontrtd标题/tdtd/tdtdinput typetext/td/trtrtd 内容/tdtd/tdtdinput typetext/td/trtrtd作者/tdtd/tdtdinput typetext/td/trtrtdinput typebutton value保存/tdtd/tdtd/td/tr/form /table *Redact.cshtml页面 model Blog.Models.Blogs; h2修改/h2 form asp-ControllerBlogs asp-actionRedact methodpostlabelIdinput asp-forId//label br/label标题input asp-forTitle//label br/label内容input asp-forContent//label br/label作者input asp-forAuthor//label br/button typesubmit保存/button /form * tableform actiontrtd标题/tdtd/tdtdinput typetext placeholder永远是朋友/td/trtrtd 内容/tdtd/tdtdinput typetext placeholder真心换一切/td/trtrtd作者/tdtd/tdtdinput typetext placeholder哈哈/td/trtrtdinput typebutton value保存/tdtd/tdtd/td/tr/form /table *
http://www.dnsts.com.cn/news/118592.html

相关文章:

  • 如何推广自己网站的关键词辽宁省建设工程信息网网址
  • 怎么知道网站是否被百度收录WordPress auto post
  • wordpress图片自动分页插件品牌关键词优化
  • 做网站一般图片的比例如何做中介网站
  • 做系统和做网站哪个简单一些安监局网站做应急预案备案
  • 集团网站建设新闻东莞建网站找哪里
  • 国家建设执业资格注册中心网站一键lnmp搭建wordpress
  • 如果做淘宝网站网络推广外包sem营销外包
  • 如何做淘宝商城网站手机主题制作软件
  • 网站上传源码后怎么弄在网上怎么注册公司
  • 抚州市建设局网站售后网站开发需求文档
  • 门户网站建设公司报价网站开发补充合同
  • 怎么在58上做公司网站好用的手机网站主页
  • 重庆的汽车网站建设wordpress里面怎么加链接
  • 镇江网站营销推广wordpress替换文字
  • 做标书有哪些好网站江西省水利水电建设集团招标网站
  • 无锡城乡建设局网站网站建设费用明细 xls
  • 在哪里申请网站wordpress资源下载插件
  • 免费做qq互赞网站哪家做网站最好
  • 做组织架构图的网站第三方仓储配送公司
  • 网上怎么免费推广seo外链工具源码
  • 柳州企业 商家应该如何做网站泉州易尔通网站建设
  • 好看的网站颜色搭配厦门seo关键词
  • 手机做app任务的网站c2c交易平台有哪些?
  • 中文域名网站跳转建设网站的要求吗
  • 建筑工程找工作哪个网站好学校建设微网站的方案
  • 怎么制作网站接口上海搜牛信息科技有限公司
  • 网站负责人姓名兰溪优秀高端网站设计地址
  • 龙文网站建设学院门户网站建设自评
  • 中山网站建设是什么意思北京广告公司地址